/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "hks_import_agree_test.h"
#include "hks_test_adapt_for_de.h"

#include <gtest/gtest.h>

#ifdef L2_STANDARD
#include "file_ex.h"
#endif

#define TEST_DATA_01 \
0x01, 0x03, 0x01, 0x30, 0x82, 0x01, 0x0c, 0x02, 0x82, 0x01, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xad, 0xf8, 0x54, 0x58, 0xa2, 0xbb, 0x4a, 0x9a, 0xaf, 0xdc, 0x56, 0x20, \
0x27, 0x3d, 0x3c, 0xf1, 0xd8, 0xb9, 0xc5, 0x83, 0xce, 0x2d, 0x36, 0x95, 0xa9, 0xe1, 0x36, 0x41, \
0x14, 0x64, 0x33, 0xfb, 0xcc, 0x93, 0x9d, 0xce, 0x24, 0x9b, 0x3e, 0xf9, 0x7d, 0x2f, 0xe3, 0x63, \
0x63, 0x0c, 0x75, 0xd8, 0xf6, 0x81, 0xb2, 0x02, 0xae, 0xc4, 0x61, 0x7a, 0xd3, 0xdf, 0x1e, 0xd5, \
0xd5, 0xfd, 0x65, 0x61, 0x24, 0x33, 0xf5, 0x1f, 0x5f, 0x06, 0x6e, 0xd0, 0x85, 0x63, 0x65, 0x55, \
0x3d, 0xed, 0x1a, 0xf3, 0xb5, 0x57, 0x13, 0x5e, 0x7f, 0x57, 0xc9, 0x35, 0x98, 0x4f, 0x0c, 0x70, \
0xe0, 0xe6, 0x8b, 0x77, 0xe2, 0xa6, 0x89, 0xda, 0xf3, 0xef, 0xe8, 0x72, 0x1d, 0xf1, 0x58, 0xa1, \
0x36, 0xad, 0xe7, 0x35, 0x30, 0xac, 0xca, 0x4f, 0x48, 0x3a, 0x79, 0x7a, 0xbc, 0x0a, 0xb1, 0x82, \
0xb3, 0x24, 0xfb, 0x61, 0xd1, 0x08, 0xa9, 0x4b, 0xb2, 0xc8, 0xe3, 0xfb, 0xb9, 0x6a, 0xda, 0xb7, \
0x60, 0xd7, 0xf4, 0x68, 0x1d, 0x4f, 0x42, 0xa3, 0xde, 0x39, 0x4d, 0xf4, 0xae, 0x56, 0xed, 0xe7, \
0x63, 0x72, 0xbb, 0x19, 0x0b, 0x07, 0xa7, 0xc8, 0xee, 0x0a, 0x6d, 0x70, 0x9e, 0x02, 0xfc, 0xe1, \
0xcd, 0xf7, 0xe2, 0xec, 0xc0, 0x34, 0x04, 0xcd, 0x28, 0x34, 0x2f, 0x61, 0x91, 0x72, 0xfe, 0x9c, \
0xe9, 0x85, 0x83, 0xff, 0x8e, 0x4f, 0x12, 0x32, 0xee, 0xf2, 0x81, 0x83, 0xc3, 0xfe, 0x3b, 0x1b, \
0x4c, 0x6f, 0xad, 0x73, 0x3b, 0xb5, 0xfc, 0xbc, 0x2e, 0xc2, 0x20, 0x05, 0xc5, 0x8e, 0xf1, 0x83, \
0x7d, 0x16, 0x83, 0xb2, 0xc6, 0xf3, 0x4a, 0x26, 0xc1, 0xb2, 0xef, 0xfa, 0x88, 0x6b, 0x42, 0x38, \
0x61, 0x28, 0x5c, 0x97, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x01, 0x02, 0x02,

#define TEST_DATA_02 \
0x30, 0x82, 0x03, 0x28, 0x30, 0x82, 0x01, 0x9b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, \
0x01, 0x03, 0x01, 0x30, 0x82, 0x01, 0x8c, 0x02, 0x82, 0x01, 0x81, 0x00, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xad, 0xf8, 0x54, 0x58, 0xa2, 0xbb, 0x4a, 0x9a, 0xaf, 0xdc, 0x56, 0x20, \
0x27, 0x3d, 0x3c, 0xf1, 0xd8, 0xb9, 0xc5, 0x83, 0xce, 0x2d, 0x36, 0x95, 0xa9, 0xe1, 0x36, 0x41, \
0x14, 0x64, 0x33, 0xfb, 0xcc, 0x93, 0x9d, 0xce, 0x24, 0x9b, 0x3e, 0xf9, 0x7d, 0x2f, 0xe3, 0x63, \
0x63, 0x0c, 0x75, 0xd8, 0xf6, 0x81, 0xb2, 0x02, 0xae, 0xc4, 0x61, 0x7a, 0xd3, 0xdf, 0x1e, 0xd5, \
0xd5, 0xfd, 0x65, 0x61, 0x24, 0x33, 0xf5, 0x1f, 0x5f, 0x06, 0x6e, 0xd0, 0x85, 0x63, 0x65, 0x55, \
0x3d, 0xed, 0x1a, 0xf3, 0xb5, 0x57, 0x13, 0x5e, 0x7f, 0x57, 0xc9, 0x35, 0x98, 0x4f, 0x0c, 0x70, \
0xe0, 0xe6, 0x8b, 0x77, 0xe2, 0xa6, 0x89, 0xda, 0xf3, 0xef, 0xe8, 0x72, 0x1d, 0xf1, 0x58, 0xa1, \
0x36, 0xad, 0xe7, 0x35, 0x30, 0xac, 0xca, 0x4f, 0x48, 0x3a, 0x79, 0x7a, 0xbc, 0x0a, 0xb1, 0x82, \
0xb3, 0x24, 0xfb, 0x61, 0xd1, 0x08, 0xa9, 0x4b, 0xb2, 0xc8, 0xe3, 0xfb, 0xb9, 0x6a, 0xda, 0xb7, \
0x60, 0xd7, 0xf4, 0x68, 0x1d, 0x4f, 0x42, 0xa3, 0xde, 0x39, 0x4d, 0xf4, 0xae, 0x56, 0xed, 0xe7, \
0x63, 0x72, 0xbb, 0x19, 0x0b, 0x07, 0xa7, 0xc8, 0xee, 0x0a, 0x6d, 0x70, 0x9e, 0x02, 0xfc, 0xe1, \
0xcd, 0xf7, 0xe2, 0xec, 0xc0, 0x34, 0x04, 0xcd, 0x28, 0x34, 0x2f, 0x61, 0x91, 0x72, 0xfe, 0x9c, \
0xe9, 0x85, 0x83, 0xff, 0x8e, 0x4f, 0x12, 0x32, 0xee, 0xf2, 0x81, 0x83, 0xc3, 0xfe, 0x3b, 0x1b, \
0x4c, 0x6f, 0xad, 0x73, 0x3b, 0xb5, 0xfc, 0xbc, 0x2e, 0xc2, 0x20, 0x05, 0xc5, 0x8e, 0xf1, 0x83, \
0x7d, 0x16, 0x83, 0xb2, 0xc6, 0xf3, 0x4a, 0x26, 0xc1, 0xb2, 0xef, 0xfa, 0x88, 0x6b, 0x42, 0x38, \
0x61, 0x1f, 0xcf, 0xdc, 0xde, 0x35, 0x5b, 0x3b, 0x65, 0x19, 0x03, 0x5b, 0xbc, 0x34, 0xf4, 0xde, \
0xf9, 0x9c, 0x02, 0x38, 0x61, 0xb4, 0x6f, 0xc9, 0xd6, 0xe6, 0xc9, 0x07, 0x7a, 0xd9, 0x1d, 0x26, \
0x91, 0xf7, 0xf7, 0xee, 0x59, 0x8c, 0xb0, 0xfa, 0xc1, 0x86, 0xd9, 0x1c, 0xae, 0xfe, 0x13, 0x09, \
0x85, 0x13, 0x92, 0x70, 0xb4, 0x13, 0x0c, 0x93, 0xbc, 0x43, 0x79, 0x44, 0xf4, 0xfd, 0x44, 0x52, \
0xe2, 0xd7, 0x4d, 0xd3, 0x64, 0xf2, 0xe2, 0x1e, 0x71, 0xf5, 0x4b, 0xff, 0x5c, 0xae, 0x82, 0xab, \
0x9c, 0x9d, 0xf6, 0x9e, 0xe8, 0x6d, 0x2b, 0xc5, 0x22, 0x36, 0x3a, 0x0d, 0xab, 0xc5, 0x21, 0x97, \
0x9b, 0x0d, 0xea, 0xda, 0x1d, 0xbf, 0x9a, 0x42, 0xd5, 0xc4, 0x48, 0x4e, 0x0a, 0xbc, 0xd0, 0x6b, \
0xfa, 0x53, 0xdd, 0xef, 0x3c, 0x1b, 0x20, 0xee, 0x3f, 0xd5, 0x9d, 0x7c, 0x25, 0xe4, 0x1d, 0x2b, \
0x66, 0xc6, 0x2e, 0x37, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x01, 0x02, 0x02,

#define TEST_DATA_03 \
0x01, 0x03, 0x01, 0x30, 0x82, 0x02, 0x0c, 0x02, 0x82, 0x02, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xad, 0xf8, 0x54, 0x58, 0xa2, 0xbb, 0x4a, 0x9a, 0xaf, 0xdc, 0x56, 0x20, \
0x27, 0x3d, 0x3c, 0xf1, 0xd8, 0xb9, 0xc5, 0x83, 0xce, 0x2d, 0x36, 0x95, 0xa9, 0xe1, 0x36, 0x41, \
0x14, 0x64, 0x33, 0xfb, 0xcc, 0x93, 0x9d, 0xce, 0x24, 0x9b, 0x3e, 0xf9, 0x7d, 0x2f, 0xe3, 0x63, \
0x63, 0x0c, 0x75, 0xd8, 0xf6, 0x81, 0xb2, 0x02, 0xae, 0xc4, 0x61, 0x7a, 0xd3, 0xdf, 0x1e, 0xd5, \
0xd5, 0xfd, 0x65, 0x61, 0x24, 0x33, 0xf5, 0x1f, 0x5f, 0x06, 0x6e, 0xd0, 0x85, 0x63, 0x65, 0x55, \
0x3d, 0xed, 0x1a, 0xf3, 0xb5, 0x57, 0x13, 0x5e, 0x7f, 0x57, 0xc9, 0x35, 0x98, 0x4f, 0x0c, 0x70, \
0xe0, 0xe6, 0x8b, 0x77, 0xe2, 0xa6, 0x89, 0xda, 0xf3, 0xef, 0xe8, 0x72, 0x1d, 0xf1, 0x58, 0xa1, \
0x36, 0xad, 0xe7, 0x35, 0x30, 0xac, 0xca, 0x4f, 0x48, 0x3a, 0x79, 0x7a, 0xbc, 0x0a, 0xb1, 0x82, \
0xb3, 0x24, 0xfb, 0x61, 0xd1, 0x08, 0xa9, 0x4b, 0xb2, 0xc8, 0xe3, 0xfb, 0xb9, 0x6a, 0xda, 0xb7,

#define TEST_DATA_04 \
0x7d, 0x16, 0x83, 0xb2, 0xc6, 0xf3, 0x4a, 0x26, 0xc1, 0xb2, 0xef, 0xfa, 0x88, 0x6b, 0x42, 0x38, \
0x61, 0x1f, 0xcf, 0xdc, 0xde, 0x35, 0x5b, 0x3b, 0x65, 0x19, 0x03, 0x5b, 0xbc, 0x34, 0xf4, 0xde, \
0xf9, 0x9c, 0x02, 0x38, 0x61, 0xb4, 0x6f, 0xc9, 0xd6, 0xe6, 0xc9, 0x07, 0x7a, 0xd9, 0x1d, 0x26, \
0x91, 0xf7, 0xf7, 0xee, 0x59, 0x8c, 0xb0, 0xfa, 0xc1, 0x86, 0xd9, 0x1c, 0xae, 0xfe, 0x13, 0x09, \
0x85, 0x13, 0x92, 0x70, 0xb4, 0x13, 0x0c, 0x93, 0xbc, 0x43, 0x79, 0x44, 0xf4, 0xfd, 0x44, 0x52, \
0xe2, 0xd7, 0x4d, 0xd3, 0x64, 0xf2, 0xe2, 0x1e, 0x71, 0xf5, 0x4b, 0xff, 0x5c, 0xae, 0x82, 0xab, \
0x9c, 0x9d, 0xf6, 0x9e, 0xe8, 0x6d, 0x2b, 0xc5, 0x22, 0x36, 0x3a, 0x0d, 0xab, 0xc5, 0x21, 0x97, \
0x9b, 0x0d, 0xea, 0xda, 0x1d, 0xbf, 0x9a, 0x42, 0xd5, 0xc4, 0x48, 0x4e, 0x0a, 0xbc, 0xd0, 0x6b, \
0xfa, 0x53, 0xdd, 0xef, 0x3c, 0x1b, 0x20, 0xee, 0x3f, 0xd5, 0x9d, 0x7c, 0x25, 0xe4, 0x1d, 0x2b, \
0x66, 0x9e, 0x1e, 0xf1, 0x6e, 0x6f, 0x52, 0xc3, 0x16, 0x4d, 0xf4, 0xfb, 0x79, 0x30, 0xe9, 0xe4, \
0xe5, 0x88, 0x57, 0xb6, 0xac, 0x7d, 0x5f, 0x42, 0xd6, 0x9f, 0x6d, 0x18, 0x77, 0x63, 0xcf, 0x1d, \
0x55, 0x03, 0x40, 0x04, 0x87, 0xf5, 0x5b, 0xa5, 0x7e, 0x31, 0xcc, 0x7a, 0x71, 0x35, 0xc8, 0x86, \
0xef, 0xb4, 0x31, 0x8a, 0xed, 0x6a, 0x1e, 0x01, 0x2d, 0x9e, 0x68, 0x32, 0xa9, 0x07, 0x60, 0x0a, \
0x91, 0x81, 0x30, 0xc4, 0x6d, 0xc7, 0x78, 0xf9, 0x71, 0xad, 0x00, 0x38, 0x09, 0x29, 0x99, 0xa3, \
0x33, 0xcb, 0x8b, 0x7a, 0x1a, 0x1d, 0xb9, 0x3d, 0x71, 0x40, 0x00, 0x3c, 0x2a, 0x4e, 0xce, 0xa9, \
0xf9, 0x8d, 0x0a, 0xcc, 0x0a, 0x82, 0x91, 0xcd, 0xce, 0xc9, 0x7d, 0xcf, 0x8e, 0xc9, 0xb5, 0x5a, \
0x7f, 0x88, 0xa4, 0x6b, 0x4d, 0xb5, 0xa8, 0x51, 0xf4, 0x41, 0x82, 0xe1, 0xc6, 0x8a, 0x00, 0x7e, \
0x5e, 0x65, 0x5f, 0x6a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x01, 0x02, 0x02,

using namespace testing::ext;
namespace Unittest::ImportAgreeTest {
class HksImportAgreeTest : public testing::Test {
public:
    static void SetUpTestCase(void);

    static void TearDownTestCase(void);

    void SetUp();

    void TearDown();
};

void HksImportAgreeTest::SetUpTestCase(void)
{
}

void HksImportAgreeTest::TearDownTestCase(void)
{
}

void HksImportAgreeTest::SetUp()
{
    EXPECT_EQ(HksInitialize(), 0);
}

void HksImportAgreeTest::TearDown()
{
}

static const uint8_t g_dhPubData2048One[] = {
    0x8a, 0xbf, 0x16, 0x67, 0x1b, 0x92, 0x4b, 0xf2, 0xe0, 0x02, 0xc5, 0x1f, 0x84, 0x00, 0xf8, 0x93,
    0x0f, 0x74, 0xe7, 0x0f, 0xba, 0x78, 0x30, 0xa8, 0x2d, 0x92, 0xef, 0x9b, 0x80, 0xeb, 0x76, 0xea,
    0x26, 0x74, 0x72, 0x63, 0x6a, 0x27, 0xc3, 0x8f, 0xcf, 0xbe, 0x82, 0xa2, 0x8b, 0xdc, 0x65, 0x58,
    0xe3, 0xff, 0x29, 0x97, 0xad, 0xb3, 0x4a, 0x2c, 0x50, 0x08, 0xb5, 0x68, 0xe1, 0x90, 0x5a, 0xdc,
    0x48, 0xb3, 0x6b, 0x7a, 0xce, 0x2e, 0x81, 0x3d, 0x38, 0x35, 0x59, 0xdc, 0x39, 0x8a, 0x97, 0xfe,
    0x20, 0x86, 0x20, 0xdb, 0x55, 0x38, 0x23, 0xca, 0xb5, 0x5b, 0x61, 0x00, 0xdc, 0x45, 0xe2, 0xa1,
    0xf4, 0x1e, 0x7b, 0x01, 0x7a, 0x84, 0x36, 0xa4, 0xa8, 0x1c, 0x0d, 0x3d, 0xde, 0x57, 0x66, 0x73,
    0x4e, 0xaf, 0xee, 0xb0, 0xb0, 0x69, 0x0c, 0x13, 0xba, 0x76, 0xff, 0x2e, 0xb6, 0x16, 0xf9, 0xfc,
    0xd6, 0x09, 0x5b, 0xc7, 0x37, 0x65, 0x84, 0xd5, 0x82, 0x8a, 0xd7, 0x5b, 0x57, 0xe3, 0x0e, 0x89,
    0xbe, 0x05, 0x05, 0x55, 0x2e, 0x9f, 0x94, 0x8a, 0x53, 0xdc, 0xb7, 0x00, 0xb2, 0x6a, 0x7b, 0x8e,
    0xdf, 0x6e, 0xa4, 0x6d, 0x13, 0xb6, 0xbc, 0xaa, 0x8e, 0x44, 0x11, 0x50, 0x32, 0x91, 0x56, 0xa2,
    0x22, 0x3f, 0x2f, 0x08, 0xbb, 0x4d, 0xbb, 0x69, 0xe6, 0xb1, 0xc2, 0x70, 0x79, 0x15, 0x54, 0xad,
    0x4a, 0x29, 0xef, 0xa9, 0x3e, 0x64, 0x8d, 0xf1, 0x90, 0xf4, 0xa7, 0x93, 0x8c, 0x7a, 0x02, 0x4d,
    0x38, 0x1f, 0x58, 0xb8, 0xe4, 0x7c, 0xe1, 0x66, 0x1c, 0x72, 0x30, 0xf3, 0x4c, 0xf4, 0x24, 0xd1,
    0x2d, 0xb7, 0xf1, 0x5a, 0x0f, 0xb8, 0x20, 0xc5, 0x90, 0xe5, 0xca, 0x45, 0x84, 0x5c, 0x08, 0x08,
    0xbf, 0xf9, 0x69, 0x41, 0xf5, 0x49, 0x85, 0x31, 0x35, 0x14, 0x69, 0x12, 0x57, 0x9c, 0xc8, 0xb7,
};

static const uint8_t g_dhPriData2048One[] = {
    0x01, 0xbc, 0xa7, 0x42, 0x25, 0x79, 0xc5, 0xaf, 0x0f, 0x9c, 0xde, 0x00, 0x3b, 0x58, 0x5c, 0xd1,
    0x1d, 0x7b, 0xcf, 0x66, 0xcd, 0xa9, 0x10, 0xae, 0x92, 0x2d, 0x3c, 0xb7, 0xf3,
};

static const uint8_t g_dhPubData3072One[] = {
    0x5b, 0xe6, 0xdc, 0xa0, 0xf7, 0x1d, 0x1a, 0xbd, 0x60, 0xd2, 0x30, 0xf1, 0x33, 0x21, 0x52, 0xfb,
    0xa6, 0x61, 0xab, 0x46, 0x49, 0xf7, 0x4e, 0xc4, 0x83, 0x9e, 0x65, 0x72, 0x5a, 0xc2, 0xc8, 0x8b,
    0xfb, 0x40, 0x0b, 0x76, 0x6e, 0x41, 0xa1, 0xf7, 0x41, 0x7e, 0x70, 0x37, 0xeb, 0x71, 0x81, 0xdf,
    0x9f, 0xca, 0x9f, 0xe0, 0x63, 0x6f, 0xae, 0xb3, 0x4d, 0x6e, 0x0b, 0x8d, 0x7e, 0xdf, 0x10, 0x1f,
    0x42, 0x57, 0x60, 0x76, 0x89, 0x1b, 0xe2, 0xbb, 0x0a, 0xe7, 0x94, 0x29, 0x93, 0x90, 0xe6, 0xf3,
    0x75, 0x6d, 0x17, 0x26, 0x49, 0xa1, 0xd8, 0x08, 0x6c, 0x1a, 0xc7, 0x30, 0x57, 0xa2, 0x8b, 0xf2,
    0x0d, 0xc8, 0x81, 0xc1, 0x16, 0xe5, 0xd3, 0x82, 0x5b, 0xda, 0x01, 0x55, 0x44, 0x18, 0x10, 0x78,
    0x10, 0x83, 0x4d, 0x7a, 0xb8, 0x05, 0x65, 0x74, 0xe7, 0xe5, 0x02, 0x17, 0x44, 0xb3, 0xca, 0x29,
    0xf9, 0xf8, 0x8d, 0x25, 0x30, 0xde, 0x18, 0xa7, 0x79, 0xa9, 0x44, 0xfe, 0x3b, 0xb9, 0x00, 0xc6,
    0xa8, 0x73, 0xb6, 0x6d, 0xae, 0x0e, 0xd4, 0xbd, 0x6c, 0x30, 0xd9, 0x60, 0xec, 0x9e, 0x3d, 0x26,
    0xd8, 0x55, 0xe2, 0xe7, 0x52, 0xf3, 0x50, 0x71, 0xc2, 0xe0, 0x61, 0x65, 0x1c, 0x8b, 0x0d, 0xfa,
    0xb5, 0x80, 0x3f, 0xfe, 0xd8, 0xcd, 0x9a, 0x2e, 0x8f, 0xc0, 0x93, 0xe4, 0x20, 0xf2, 0x5f, 0x51,
    0xb3, 0xc9, 0x77, 0xd8, 0x01, 0x5b, 0x06, 0xa0, 0xa5, 0x13, 0xe2, 0x63, 0xef, 0x93, 0x26, 0x77,
    0x5c, 0x2a, 0x97, 0x77, 0x35, 0x54, 0xe5, 0xb2, 0xfd, 0xaa, 0x8a, 0x15, 0xae, 0xff, 0x1a, 0x74,
    0x61, 0x9f, 0xe1, 0xf2, 0xa6, 0x72, 0xb1, 0x07, 0xb6, 0x8c, 0x3e, 0xf7, 0xfa, 0xe6, 0x45, 0xdb,
    0xa0, 0xd1, 0x55, 0x36, 0x6d, 0xe3, 0xbb, 0x85, 0xdb, 0x57, 0x33, 0x40, 0xbc, 0xee, 0xd1, 0x54,
    0x93, 0x7e, 0x24, 0x04, 0x2d, 0x8e, 0x98, 0x69, 0xbc, 0xcc, 0xdf, 0xb3, 0x32, 0xe6, 0x67, 0x03,
    0x10, 0xea, 0xb9, 0xa4, 0x25, 0x81, 0xdf, 0x4a, 0x5c, 0x53, 0xf4, 0x56, 0x44, 0xbb, 0xc0, 0x79,
    0xe8, 0x96, 0xe3, 0xae, 0x72, 0xbf, 0xd3, 0x15, 0xfd, 0x2c, 0x83, 0xa9, 0x9f, 0x3d, 0xdd, 0xce,
    0xcf, 0xd4, 0xab, 0x04, 0xf2, 0x15, 0x03, 0x4e, 0x02, 0x2f, 0xef, 0x44, 0x6a, 0xd3, 0x8b, 0x25,
    0xde, 0xca, 0x79, 0x3d, 0x55, 0x10, 0xba, 0xcb, 0x00, 0x16, 0x1c, 0xd3, 0xe7, 0x56, 0x70, 0x11,
    0xad, 0xbe, 0xdd, 0xc8, 0x02, 0x4c, 0x4a, 0xe3, 0x85, 0x9f, 0xfe, 0xd9, 0x75, 0x7d, 0x9a, 0x4d,
    0x6c, 0x59, 0x20, 0x0f, 0x4d, 0xe7, 0xdc, 0x45, 0xd2, 0x87, 0x60, 0x61, 0xce, 0x88, 0xa1, 0x66,
    0xe4, 0xc2, 0xc0, 0x9a, 0xff, 0x91, 0x5f, 0xf1, 0xba, 0x97, 0x13, 0x85, 0x48, 0x03, 0xbb, 0xc7,
};

static const uint8_t g_dhPriData3072One[] = {
    0x06, 0x9f, 0x54, 0x48, 0x45, 0x01, 0x81, 0x71, 0xc4, 0x77, 0xf9, 0x9e, 0x8b, 0x43, 0x4b, 0x78,
    0x0d, 0xf4, 0x1b, 0xc2, 0xa9, 0xc5, 0x7a, 0xa0, 0xd5, 0x46, 0x8b, 0xd2, 0xc9, 0xf5, 0x60, 0xd3,
    0xcb, 0x57, 0x12,
};

static const uint8_t g_dhPubData4096One[] = {
    0x8a, 0x1b, 0x02, 0xc9, 0xb7, 0xa3, 0x74, 0x21, 0x2a, 0xee, 0x06, 0x2a, 0xd9, 0xc0, 0xb4, 0x5c,
    0xec, 0x2f, 0x0d, 0xdd, 0x88, 0x07, 0x77, 0xf6, 0xcb, 0xd5, 0x43, 0x46, 0x4d, 0x56, 0xff, 0x1a,
    0x03, 0x68, 0xa8, 0x4e, 0x73, 0x09, 0x07, 0x10, 0x9d, 0x00, 0xea, 0xb4, 0x44, 0x9c, 0x67, 0x5c,
    0xf1, 0xe9, 0xb0, 0x21, 0x49, 0x5a, 0x2d, 0xa9, 0x9d, 0xf8, 0xce, 0x71, 0x19, 0x2b, 0x20, 0x02,
    0x25, 0x6f, 0xb5, 0xcd, 0x9f, 0x6d, 0x34, 0xf5, 0x87, 0x75, 0x42, 0xed, 0xa1, 0x21, 0x07, 0x33,
    0xcd, 0xc3, 0x7b, 0x17, 0xd9, 0x94, 0xe7, 0x4d, 0x31, 0xfc, 0x94, 0x83, 0xfe, 0x32, 0xc3, 0x7b,
    0x18, 0x16, 0x8c, 0x64, 0x8d, 0x31, 0x57, 0xb2, 0xf3, 0xf4, 0xfa, 0xa3, 0x84, 0x3c, 0x1f, 0x5f,
    0x77, 0x86, 0xcf, 0xd4, 0x4c, 0x7b, 0xf9, 0x6a, 0xe3, 0x0a, 0xa7, 0x10, 0xad, 0x8c, 0xab, 0x4f,
    0x2f, 0x85, 0x0c, 0x67, 0xb3, 0x80, 0xcc, 0xe7, 0x60, 0x0e, 0xe4, 0xc7, 0x75, 0x07, 0x41, 0x75,
    0x2a, 0x8a, 0xfc, 0x81, 0xe2, 0x34, 0xcd, 0x7a, 0xe1, 0xb7, 0xf1, 0x88, 0xa0, 0x6f, 0x84, 0xa2,
    0xe7, 0x8f, 0x4e, 0x40, 0xba, 0xbe, 0x92, 0xfa, 0xb9, 0x60, 0x50, 0x5d, 0x0e, 0x44, 0xce, 0x17,
    0x3c, 0x34, 0x46, 0x74, 0x8d, 0xc3, 0xbd, 0x61, 0xf2, 0xab, 0x6c, 0x49, 0x02, 0x60, 0xf7, 0xdf,
    0xb3, 0x79, 0xe7, 0xcb, 0x02, 0xc5, 0x01, 0x84, 0x15, 0xbe, 0xe2, 0x43, 0x24, 0xa3, 0x90, 0xa8,
    0x12, 0x06, 0x90, 0x1a, 0x93, 0x33, 0xb7, 0x5c, 0xf1, 0x5a, 0xea, 0x93, 0x70, 0x11, 0x18, 0xc5,
    0xd3, 0xb2, 0xe9, 0x53, 0x1d, 0x77, 0x88, 0x68, 0x58, 0x18, 0x64, 0x62, 0xfd, 0x19, 0x4d, 0x25,
    0x54, 0xc6, 0x10, 0x32, 0x48, 0x02, 0xd0, 0x3f, 0x31, 0x69, 0xcf, 0x2f, 0x25, 0xfc, 0xab, 0xee,
    0xc6, 0x57, 0x5a, 0x7e, 0x21, 0x9c, 0x9e, 0x63, 0xfa, 0xd7, 0xb5, 0xa1, 0x49, 0x61, 0xe4, 0xd0,
    0xea, 0x1e, 0xb8, 0x62, 0xc5, 0x0a, 0x57, 0xc7, 0x37, 0xf0, 0x0e, 0x97, 0xf9, 0x4e, 0xc5, 0xc7,
    0x3e, 0xc2, 0x97, 0xc4, 0xf6, 0x40, 0x28, 0xdb, 0xf0, 0x17, 0xa7, 0x2c, 0xfb, 0xef, 0x63, 0x7d,
    0xcd, 0xe3, 0x37, 0x24, 0x49, 0x15, 0x97, 0x99, 0xb7, 0xb5, 0x78, 0xde, 0x64, 0xd7, 0xe2, 0x2d,
    0xdc, 0x68, 0x1a, 0xdd, 0xb9, 0x33, 0x50, 0x42, 0xd5, 0xe4, 0x2a, 0x9c, 0x87, 0x71, 0x8f, 0x20,
    0x30, 0x2e, 0x04, 0x1c, 0x38, 0x73, 0x3f, 0xf7, 0x7a, 0x6a, 0x1c, 0x36, 0x5e, 0x83, 0x87, 0xde,
    0x9d, 0x01, 0xa0, 0x3e, 0xea, 0x3c, 0x44, 0xb1, 0xd9, 0x3d, 0x80, 0x20, 0x02, 0x30, 0x3a, 0x00,
    0x6f, 0xed, 0xb3, 0x1e, 0xbe, 0xdf, 0x7e, 0xaa, 0x48, 0x98, 0xe7, 0x81, 0x49, 0x45, 0x3e, 0x74,
    0x89, 0xd1, 0xd4, 0x1e, 0x23, 0xc6, 0xd8, 0x45, 0x6a, 0x83, 0xc5, 0x6b, 0xca, 0xad, 0xe7, 0x38,
    0x33, 0xee, 0x04, 0x84, 0x1c, 0x48, 0x54, 0x63, 0x4a, 0xe8, 0x15, 0x79, 0x9d, 0xdb, 0xd6, 0x2a,
    0xf0, 0xbb, 0xaa, 0xa9, 0x6e, 0x60, 0xda, 0x82, 0x98, 0x7e, 0xcf, 0xf0, 0x50, 0xd5, 0x26, 0xf7,
    0x58, 0x5f, 0x72, 0x5b, 0xc9, 0x67, 0x81, 0x64, 0x0c, 0x30, 0x02, 0x55, 0x87, 0xb3, 0x14, 0xa8,
    0x2d, 0x21, 0x31, 0xef, 0x2e, 0xe0, 0x1d, 0x2e, 0x22, 0xee, 0xab, 0xf3, 0x28, 0x05, 0x87, 0xdc,
    0x06, 0x32, 0x87, 0xf1, 0x0d, 0xbe, 0x98, 0x61, 0x24, 0x4f, 0x71, 0xd4, 0x6a, 0xc4, 0x00, 0x06,
    0xf8, 0x3b, 0x46, 0x98, 0xb4, 0x77, 0x4a, 0x6c, 0xe4, 0x1a, 0x00, 0xb8, 0x4f, 0x63, 0x61, 0x8e,
    0xaa, 0x0f, 0x6f, 0x27, 0xe8, 0x91, 0x70, 0x88, 0x0d, 0x50, 0xd3, 0xa9, 0x25, 0xfe, 0x33, 0xb0,
};
static const uint8_t g_dhPriData4096One[] = {
    0x1c, 0x34, 0x9b, 0xd3, 0xf0, 0x76, 0xa8, 0xb8, 0x25, 0x3a, 0xa3, 0xc7, 0xb4, 0x8f, 0xbb, 0x3c,
    0xf8, 0x0f, 0x73, 0xf4, 0x21, 0x03, 0x95, 0x53, 0xa8, 0xec, 0x95, 0x49, 0xa0, 0x83, 0x33, 0x95,
    0x22, 0x19, 0xf7, 0x10, 0xc8, 0x19, 0xc1, 0x85, 0xa9,
};

static const uint8_t g_dhX509PubData2048One[] = {
    0x30, 0x82, 0x02, 0x29, 0x30, 0x82, 0x01, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
    TEST_DATA_01
    0x02, 0x00, 0xe1, 0x03, 0x82, 0x01, 0x06, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0x8a, 0xbf, 0x16,
    0x67, 0x1b, 0x92, 0x4b, 0xf2, 0xe0, 0x02, 0xc5, 0x1f, 0x84, 0x00, 0xf8, 0x93, 0x0f, 0x74, 0xe7,
    0x0f, 0xba, 0x78, 0x30, 0xa8, 0x2d, 0x92, 0xef, 0x9b, 0x80, 0xeb, 0x76, 0xea, 0x26, 0x74, 0x72,
    0x63, 0x6a, 0x27, 0xc3, 0x8f, 0xcf, 0xbe, 0x82, 0xa2, 0x8b, 0xdc, 0x65, 0x58, 0xe3, 0xff, 0x29,
    0x97, 0xad, 0xb3, 0x4a, 0x2c, 0x50, 0x08, 0xb5, 0x68, 0xe1, 0x90, 0x5a, 0xdc, 0x48, 0xb3, 0x6b,
    0x7a, 0xce, 0x2e, 0x81, 0x3d, 0x38, 0x35, 0x59, 0xdc, 0x39, 0x8a, 0x97, 0xfe, 0x20, 0x86, 0x20,
    0xdb, 0x55, 0x38, 0x23, 0xca, 0xb5, 0x5b, 0x61, 0x00, 0xdc, 0x45, 0xe2, 0xa1, 0xf4, 0x1e, 0x7b,
    0x01, 0x7a, 0x84, 0x36, 0xa4, 0xa8, 0x1c, 0x0d, 0x3d, 0xde, 0x57, 0x66, 0x73, 0x4e, 0xaf, 0xee,
    0xb0, 0xb0, 0x69, 0x0c, 0x13, 0xba, 0x76, 0xff, 0x2e, 0xb6, 0x16, 0xf9, 0xfc, 0xd6, 0x09, 0x5b,
    0xc7, 0x37, 0x65, 0x84, 0xd5, 0x82, 0x8a, 0xd7, 0x5b, 0x57, 0xe3, 0x0e, 0x89, 0xbe, 0x05, 0x05,
    0x55, 0x2e, 0x9f, 0x94, 0x8a, 0x53, 0xdc, 0xb7, 0x00, 0xb2, 0x6a, 0x7b, 0x8e, 0xdf, 0x6e, 0xa4,
    0x6d, 0x13, 0xb6, 0xbc, 0xaa, 0x8e, 0x44, 0x11, 0x50, 0x32, 0x91, 0x56, 0xa2, 0x22, 0x3f, 0x2f,
    0x08, 0xbb, 0x4d, 0xbb, 0x69, 0xe6, 0xb1, 0xc2, 0x70, 0x79, 0x15, 0x54, 0xad, 0x4a, 0x29, 0xef,
    0xa9, 0x3e, 0x64, 0x8d, 0xf1, 0x90, 0xf4, 0xa7, 0x93, 0x8c, 0x7a, 0x02, 0x4d, 0x38, 0x1f, 0x58,
    0xb8, 0xe4, 0x7c, 0xe1, 0x66, 0x1c, 0x72, 0x30, 0xf3, 0x4c, 0xf4, 0x24, 0xd1, 0x2d, 0xb7, 0xf1,
    0x5a, 0x0f, 0xb8, 0x20, 0xc5, 0x90, 0xe5, 0xca, 0x45, 0x84, 0x5c, 0x08, 0x08, 0xbf, 0xf9, 0x69,
    0x41, 0xf5, 0x49, 0x85, 0x31, 0x35, 0x14, 0x69, 0x12, 0x57, 0x9c, 0xc8, 0xb7,
};

static const uint8_t g_dhX509PubData3072One[] = {
    TEST_DATA_02
    0x02, 0x01, 0x13, 0x03, 0x82, 0x01, 0x85, 0x00, 0x02, 0x82, 0x01, 0x80, 0x5b, 0xe6, 0xdc, 0xa0,
    0xf7, 0x1d, 0x1a, 0xbd, 0x60, 0xd2, 0x30, 0xf1, 0x33, 0x21, 0x52, 0xfb, 0xa6, 0x61, 0xab, 0x46,
    0x49, 0xf7, 0x4e, 0xc4, 0x83, 0x9e, 0x65, 0x72, 0x5a, 0xc2, 0xc8, 0x8b, 0xfb, 0x40, 0x0b, 0x76,
    0x6e, 0x41, 0xa1, 0xf7, 0x41, 0x7e, 0x70, 0x37, 0xeb, 0x71, 0x81, 0xdf, 0x9f, 0xca, 0x9f, 0xe0,
    0x63, 0x6f, 0xae, 0xb3, 0x4d, 0x6e, 0x0b, 0x8d, 0x7e, 0xdf, 0x10, 0x1f, 0x42, 0x57, 0x60, 0x76,
    0x89, 0x1b, 0xe2, 0xbb, 0x0a, 0xe7, 0x94, 0x29, 0x93, 0x90, 0xe6, 0xf3, 0x75, 0x6d, 0x17, 0x26,
    0x49, 0xa1, 0xd8, 0x08, 0x6c, 0x1a, 0xc7, 0x30, 0x57, 0xa2, 0x8b, 0xf2, 0x0d, 0xc8, 0x81, 0xc1,
    0x16, 0xe5, 0xd3, 0x82, 0x5b, 0xda, 0x01, 0x55, 0x44, 0x18, 0x10, 0x78, 0x10, 0x83, 0x4d, 0x7a,
    0xb8, 0x05, 0x65, 0x74, 0xe7, 0xe5, 0x02, 0x17, 0x44, 0xb3, 0xca, 0x29, 0xf9, 0xf8, 0x8d, 0x25,
    0x30, 0xde, 0x18, 0xa7, 0x79, 0xa9, 0x44, 0xfe, 0x3b, 0xb9, 0x00, 0xc6, 0xa8, 0x73, 0xb6, 0x6d,
    0xae, 0x0e, 0xd4, 0xbd, 0x6c, 0x30, 0xd9, 0x60, 0xec, 0x9e, 0x3d, 0x26, 0xd8, 0x55, 0xe2, 0xe7,
    0x52, 0xf3, 0x50, 0x71, 0xc2, 0xe0, 0x61, 0x65, 0x1c, 0x8b, 0x0d, 0xfa, 0xb5, 0x80, 0x3f, 0xfe,
    0xd8, 0xcd, 0x9a, 0x2e, 0x8f, 0xc0, 0x93, 0xe4, 0x20, 0xf2, 0x5f, 0x51, 0xb3, 0xc9, 0x77, 0xd8,
    0x01, 0x5b, 0x06, 0xa0, 0xa5, 0x13, 0xe2, 0x63, 0xef, 0x93, 0x26, 0x77, 0x5c, 0x2a, 0x97, 0x77,
    0x35, 0x54, 0xe5, 0xb2, 0xfd, 0xaa, 0x8a, 0x15, 0xae, 0xff, 0x1a, 0x74, 0x61, 0x9f, 0xe1, 0xf2,
    0xa6, 0x72, 0xb1, 0x07, 0xb6, 0x8c, 0x3e, 0xf7, 0xfa, 0xe6, 0x45, 0xdb, 0xa0, 0xd1, 0x55, 0x36,
    0x6d, 0xe3, 0xbb, 0x85, 0xdb, 0x57, 0x33, 0x40, 0xbc, 0xee, 0xd1, 0x54, 0x93, 0x7e, 0x24, 0x04,
    0x2d, 0x8e, 0x98, 0x69, 0xbc, 0xcc, 0xdf, 0xb3, 0x32, 0xe6, 0x67, 0x03, 0x10, 0xea, 0xb9, 0xa4,
    0x25, 0x81, 0xdf, 0x4a, 0x5c, 0x53, 0xf4, 0x56, 0x44, 0xbb, 0xc0, 0x79, 0xe8, 0x96, 0xe3, 0xae,
    0x72, 0xbf, 0xd3, 0x15, 0xfd, 0x2c, 0x83, 0xa9, 0x9f, 0x3d, 0xdd, 0xce, 0xcf, 0xd4, 0xab, 0x04,
    0xf2, 0x15, 0x03, 0x4e, 0x02, 0x2f, 0xef, 0x44, 0x6a, 0xd3, 0x8b, 0x25, 0xde, 0xca, 0x79, 0x3d,
    0x55, 0x10, 0xba, 0xcb, 0x00, 0x16, 0x1c, 0xd3, 0xe7, 0x56, 0x70, 0x11, 0xad, 0xbe, 0xdd, 0xc8,
    0x02, 0x4c, 0x4a, 0xe3, 0x85, 0x9f, 0xfe, 0xd9, 0x75, 0x7d, 0x9a, 0x4d, 0x6c, 0x59, 0x20, 0x0f,
    0x4d, 0xe7, 0xdc, 0x45, 0xd2, 0x87, 0x60, 0x61, 0xce, 0x88, 0xa1, 0x66, 0xe4, 0xc2, 0xc0, 0x9a,
    0xff, 0x91, 0x5f, 0xf1, 0xba, 0x97, 0x13, 0x85, 0x48, 0x03, 0xbb, 0xc7,
};
static const uint8_t g_dhX509PubData4096One[] = {
    0x30, 0x82, 0x04, 0x29, 0x30, 0x82, 0x02, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
    TEST_DATA_03
    0x60, 0xd7, 0xf4, 0x68, 0x1d, 0x4f, 0x42, 0xa3, 0xde, 0x39, 0x4d, 0xf4, 0xae, 0x56, 0xed, 0xe7,
    0x63, 0x72, 0xbb, 0x19, 0x0b, 0x07, 0xa7, 0xc8, 0xee, 0x0a, 0x6d, 0x70, 0x9e, 0x02, 0xfc, 0xe1,
    0xcd, 0xf7, 0xe2, 0xec, 0xc0, 0x34, 0x04, 0xcd, 0x28, 0x34, 0x2f, 0x61, 0x91, 0x72, 0xfe, 0x9c,
    0xe9, 0x85, 0x83, 0xff, 0x8e, 0x4f, 0x12, 0x32, 0xee, 0xf2, 0x81, 0x83, 0xc3, 0xfe, 0x3b, 0x1b,
    0x4c, 0x6f, 0xad, 0x73, 0x3b, 0xb5, 0xfc, 0xbc, 0x2e, 0xc2, 0x20, 0x05, 0xc5, 0x8e, 0xf1, 0x83,
    TEST_DATA_04
    0x02, 0x01, 0x45, 0x03, 0x82, 0x02, 0x06, 0x00, 0x02, 0x82, 0x02, 0x01, 0x00, 0x8a, 0x1b, 0x02,
    0xc9, 0xb7, 0xa3, 0x74, 0x21, 0x2a, 0xee, 0x06, 0x2a, 0xd9, 0xc0, 0xb4, 0x5c, 0xec, 0x2f, 0x0d,
    0xdd, 0x88, 0x07, 0x77, 0xf6, 0xcb, 0xd5, 0x43, 0x46, 0x4d, 0x56, 0xff, 0x1a, 0x03, 0x68, 0xa8,
    0x4e, 0x73, 0x09, 0x07, 0x10, 0x9d, 0x00, 0xea, 0xb4, 0x44, 0x9c, 0x67, 0x5c, 0xf1, 0xe9, 0xb0,
    0x21, 0x49, 0x5a, 0x2d, 0xa9, 0x9d, 0xf8, 0xce, 0x71, 0x19, 0x2b, 0x20, 0x02, 0x25, 0x6f, 0xb5,
    0xcd, 0x9f, 0x6d, 0x34, 0xf5, 0x87, 0x75, 0x42, 0xed, 0xa1, 0x21, 0x07, 0x33, 0xcd, 0xc3, 0x7b,
    0x17, 0xd9, 0x94, 0xe7, 0x4d, 0x31, 0xfc, 0x94, 0x83, 0xfe, 0x32, 0xc3, 0x7b, 0x18, 0x16, 0x8c,
    0x64, 0x8d, 0x31, 0x57, 0xb2, 0xf3, 0xf4, 0xfa, 0xa3, 0x84, 0x3c, 0x1f, 0x5f, 0x77, 0x86, 0xcf,
    0xd4, 0x4c, 0x7b, 0xf9, 0x6a, 0xe3, 0x0a, 0xa7, 0x10, 0xad, 0x8c, 0xab, 0x4f, 0x2f, 0x85, 0x0c,
    0x67, 0xb3, 0x80, 0xcc, 0xe7, 0x60, 0x0e, 0xe4, 0xc7, 0x75, 0x07, 0x41, 0x75, 0x2a, 0x8a, 0xfc,
    0x81, 0xe2, 0x34, 0xcd, 0x7a, 0xe1, 0xb7, 0xf1, 0x88, 0xa0, 0x6f, 0x84, 0xa2, 0xe7, 0x8f, 0x4e,
    0x40, 0xba, 0xbe, 0x92, 0xfa, 0xb9, 0x60, 0x50, 0x5d, 0x0e, 0x44, 0xce, 0x17, 0x3c, 0x34, 0x46,
    0x74, 0x8d, 0xc3, 0xbd, 0x61, 0xf2, 0xab, 0x6c, 0x49, 0x02, 0x60, 0xf7, 0xdf, 0xb3, 0x79, 0xe7,
    0xcb, 0x02, 0xc5, 0x01, 0x84, 0x15, 0xbe, 0xe2, 0x43, 0x24, 0xa3, 0x90, 0xa8, 0x12, 0x06, 0x90,
    0x1a, 0x93, 0x33, 0xb7, 0x5c, 0xf1, 0x5a, 0xea, 0x93, 0x70, 0x11, 0x18, 0xc5, 0xd3, 0xb2, 0xe9,
    0x53, 0x1d, 0x77, 0x88, 0x68, 0x58, 0x18, 0x64, 0x62, 0xfd, 0x19, 0x4d, 0x25, 0x54, 0xc6, 0x10,
    0x32, 0x48, 0x02, 0xd0, 0x3f, 0x31, 0x69, 0xcf, 0x2f, 0x25, 0xfc, 0xab, 0xee, 0xc6, 0x57, 0x5a,
    0x7e, 0x21, 0x9c, 0x9e, 0x63, 0xfa, 0xd7, 0xb5, 0xa1, 0x49, 0x61, 0xe4, 0xd0, 0xea, 0x1e, 0xb8,
    0x62, 0xc5, 0x0a, 0x57, 0xc7, 0x37, 0xf0, 0x0e, 0x97, 0xf9, 0x4e, 0xc5, 0xc7, 0x3e, 0xc2, 0x97,
    0xc4, 0xf6, 0x40, 0x28, 0xdb, 0xf0, 0x17, 0xa7, 0x2c, 0xfb, 0xef, 0x63, 0x7d, 0xcd, 0xe3, 0x37,
    0x24, 0x49, 0x15, 0x97, 0x99, 0xb7, 0xb5, 0x78, 0xde, 0x64, 0xd7, 0xe2, 0x2d, 0xdc, 0x68, 0x1a,
    0xdd, 0xb9, 0x33, 0x50, 0x42, 0xd5, 0xe4, 0x2a, 0x9c, 0x87, 0x71, 0x8f, 0x20, 0x30, 0x2e, 0x04,
    0x1c, 0x38, 0x73, 0x3f, 0xf7, 0x7a, 0x6a, 0x1c, 0x36, 0x5e, 0x83, 0x87, 0xde, 0x9d, 0x01, 0xa0,
    0x3e, 0xea, 0x3c, 0x44, 0xb1, 0xd9, 0x3d, 0x80, 0x20, 0x02, 0x30, 0x3a, 0x00, 0x6f, 0xed, 0xb3,
    0x1e, 0xbe, 0xdf, 0x7e, 0xaa, 0x48, 0x98, 0xe7, 0x81, 0x49, 0x45, 0x3e, 0x74, 0x89, 0xd1, 0xd4,
    0x1e, 0x23, 0xc6, 0xd8, 0x45, 0x6a, 0x83, 0xc5, 0x6b, 0xca, 0xad, 0xe7, 0x38, 0x33, 0xee, 0x04,
    0x84, 0x1c, 0x48, 0x54, 0x63, 0x4a, 0xe8, 0x15, 0x79, 0x9d, 0xdb, 0xd6, 0x2a, 0xf0, 0xbb, 0xaa,
    0xa9, 0x6e, 0x60, 0xda, 0x82, 0x98, 0x7e, 0xcf, 0xf0, 0x50, 0xd5, 0x26, 0xf7, 0x58, 0x5f, 0x72,
    0x5b, 0xc9, 0x67, 0x81, 0x64, 0x0c, 0x30, 0x02, 0x55, 0x87, 0xb3, 0x14, 0xa8, 0x2d, 0x21, 0x31,
    0xef, 0x2e, 0xe0, 0x1d, 0x2e, 0x22, 0xee, 0xab, 0xf3, 0x28, 0x05, 0x87, 0xdc, 0x06, 0x32, 0x87,
    0xf1, 0x0d, 0xbe, 0x98, 0x61, 0x24, 0x4f, 0x71, 0xd4, 0x6a, 0xc4, 0x00, 0x06, 0xf8, 0x3b, 0x46,
    0x98, 0xb4, 0x77, 0x4a, 0x6c, 0xe4, 0x1a, 0x00, 0xb8, 0x4f, 0x63, 0x61, 0x8e, 0xaa, 0x0f, 0x6f,
    0x27, 0xe8, 0x91, 0x70, 0x88, 0x0d, 0x50, 0xd3, 0xa9, 0x25, 0xfe, 0x33, 0xb0,
};

static const uint8_t g_dhPubData2048Two[] = {
    0x6f, 0xe6, 0x00, 0x72, 0x0e, 0xe2, 0x20, 0x33, 0x05, 0x4a, 0xf4, 0xff, 0x55, 0x27, 0x20, 0x6b,
    0xa8, 0x9a, 0x96, 0x0b, 0xa3, 0x09, 0x4f, 0x5a, 0xaa, 0x49, 0x57, 0xcc, 0x43, 0x94, 0x20, 0x56,
    0x6d, 0xf8, 0x32, 0x46, 0x36, 0x9e, 0x94, 0x70, 0x13, 0xbe, 0x68, 0xfa, 0x2a, 0xdb, 0xd8, 0x33,
    0x9f, 0x9d, 0x0b, 0x13, 0x89, 0xba, 0xd6, 0xe2, 0x68, 0x57, 0x40, 0x60, 0x97, 0xea, 0xde, 0x1f,
    0x8c, 0xf7, 0xe1, 0xb7, 0x73, 0x67, 0x31, 0x26, 0x95, 0x1b, 0x71, 0x24, 0x9e, 0x4d, 0xc6, 0x8b,
    0x6f, 0x00, 0x5a, 0x71, 0xf3, 0x4a, 0xdc, 0xf1, 0x61, 0xab, 0xc5, 0x50, 0xda, 0xc6, 0x5d, 0xa1,
    0x23, 0xaa, 0x13, 0x5a, 0x03, 0xc3, 0x97, 0xe6, 0x92, 0x5a, 0x57, 0x94, 0xa2, 0x2b, 0x52, 0x91,
    0xc6, 0x4a, 0x74, 0xe9, 0x06, 0x6b, 0x71, 0x70, 0x47, 0xe0, 0xf9, 0x2b, 0xa0, 0x15, 0x0c, 0xa7,
    0x36, 0xdb, 0xfb, 0x41, 0x65, 0x3f, 0xfc, 0x27, 0x75, 0xf1, 0x0a, 0xe3, 0x8f, 0x64, 0x27, 0x5c,
    0x71, 0x6d, 0x32, 0x1b, 0x71, 0x2c, 0xbd, 0x89, 0xee, 0xec, 0xa8, 0x0e, 0x8d, 0xaf, 0xef, 0xd8,
    0x88, 0xf5, 0x33, 0x3c, 0x22, 0x2b, 0x96, 0xb6, 0x75, 0x9e, 0x3a, 0x5b, 0xcb, 0x20, 0x84, 0xf5,
    0x69, 0x22, 0x52, 0x42, 0x70, 0x44, 0x61, 0x24, 0x52, 0x2a, 0x3e, 0xa0, 0x1d, 0xa3, 0x85, 0x65,
    0x21, 0x91, 0x6f, 0x06, 0xcb, 0x29, 0x28, 0xaf, 0xf4, 0x17, 0x83, 0x35, 0x6a, 0xe3, 0x14, 0x77,
    0x13, 0x3b, 0x97, 0xbd, 0xd4, 0x3b, 0xb2, 0x8e, 0x58, 0xd5, 0x8d, 0x1f, 0x17, 0x09, 0xe0, 0x94,
    0xf1, 0xe7, 0xd3, 0x28, 0x97, 0x6c, 0xb2, 0x7d, 0xd7, 0x4d, 0x40, 0x04, 0x02, 0x18, 0xb2, 0xa8,
    0x63, 0x5a, 0x23, 0x43, 0xd1, 0xfc, 0xe0, 0xd6, 0x06, 0x40, 0xc0, 0x94, 0xf9, 0x12, 0x5e, 0x20,
};

static const uint8_t g_dhPriData2048Two[] = {
    0x01, 0xfb, 0x0b, 0xa7, 0x71, 0xc7, 0xf7, 0xd6, 0x89, 0x2e, 0x62, 0x22, 0xea, 0x52, 0x9e, 0x50,
    0x8d, 0x66, 0xa7, 0xda, 0xbb, 0x3d, 0x60, 0xcb, 0xb3, 0x54, 0xef, 0x5f, 0xce,
};

static const uint8_t g_dhPubData3072Two[] = {
    0x39, 0xe9, 0x5c, 0xce, 0x99, 0x1e, 0x57, 0x84, 0xcc, 0x32, 0x68, 0xdf, 0x5f, 0x79, 0x9e, 0x24,
    0xf5, 0xbb, 0xc8, 0x4d, 0xc9, 0xce, 0x2d, 0x99, 0xe9, 0x69, 0xb9, 0xdc, 0xac, 0x82, 0x58, 0xa2,
    0x84, 0xa2, 0xc9, 0x34, 0xc6, 0xef, 0x58, 0xb6, 0xc7, 0xfc, 0xf2, 0xe4, 0x01, 0xed, 0x70, 0xf1,
    0x05, 0x6f, 0xd0, 0x26, 0x55, 0x3f, 0x6a, 0xb0, 0xbd, 0x83, 0x3d, 0x5d, 0x54, 0x6c, 0xed, 0x39,
    0x13, 0x44, 0xfb, 0xbf, 0xef, 0xb3, 0xb1, 0xc3, 0x83, 0x95, 0xb8, 0xce, 0x71, 0x26, 0x4b, 0x2e,
    0xdc, 0x4f, 0xe8, 0x4b, 0x87, 0x7e, 0x6e, 0x01, 0xa9, 0x00, 0x69, 0x7a, 0x52, 0xd2, 0x4b, 0xc2,
    0xb9, 0xb4, 0xbe, 0xb6, 0xea, 0xd8, 0x82, 0x32, 0xea, 0x6e, 0x25, 0xb6, 0x0b, 0x7b, 0x3a, 0x97,
    0x61, 0xac, 0x17, 0xba, 0xd3, 0xf0, 0x05, 0x09, 0x36, 0x95, 0x42, 0x04, 0x6a, 0x1c, 0x43, 0xed,
    0x85, 0xf8, 0x67, 0x7f, 0xe0, 0x2c, 0x37, 0xd8, 0x23, 0x86, 0x23, 0xb0, 0xba, 0x9b, 0x84, 0x9a,
    0x30, 0xe3, 0xec, 0x10, 0x2a, 0x25, 0x33, 0x90, 0x5f, 0x7f, 0xd2, 0xbe, 0xad, 0xea, 0xd3, 0x75,
    0xc2, 0xe1, 0x50, 0x62, 0x5d, 0xd8, 0xb1, 0xbe, 0xc9, 0x3a, 0xd5, 0x33, 0xa1, 0x41, 0x93, 0x33,
    0xad, 0xc7, 0x26, 0x00, 0xb1, 0x18, 0x27, 0x55, 0x65, 0x11, 0xbe, 0x4b, 0x46, 0x8e, 0x3b, 0x82,
    0x76, 0x48, 0x52, 0xca, 0x13, 0x1c, 0xab, 0xa1, 0xa5, 0x3e, 0xca, 0xc5, 0x90, 0x74, 0x35, 0x29,
    0x6b, 0x85, 0xa9, 0xd8, 0xe5, 0x74, 0xeb, 0xff, 0xbf, 0x60, 0x4d, 0x32, 0x0f, 0xc3, 0x2d, 0xba,
    0x0d, 0xad, 0xe7, 0xf3, 0x49, 0x96, 0x93, 0x04, 0x94, 0x2e, 0x4c, 0x84, 0x34, 0x10, 0x47, 0x72,
    0x9d, 0xd0, 0x0e, 0xa8, 0x7b, 0x2f, 0xf2, 0xed, 0xf3, 0xda, 0xa8, 0x69, 0x95, 0xef, 0x0e, 0x20,
    0x93, 0x22, 0x3a, 0x4f, 0x25, 0x7f, 0x1f, 0xd4, 0x0b, 0x23, 0x79, 0x54, 0xeb, 0x87, 0xbd, 0x20,
    0x78, 0x1e, 0x36, 0x8e, 0x42, 0x6f, 0x53, 0xb1, 0xa1, 0x04, 0x82, 0x70, 0x22, 0xf2, 0x32, 0xd6,
    0x62, 0xe0, 0x12, 0xa8, 0x8b, 0x57, 0x08, 0x01, 0xf9, 0x66, 0x06, 0x25, 0xda, 0xe7, 0xd8, 0x4b,
    0x69, 0xb4, 0x5f, 0xca, 0xbe, 0x63, 0x05, 0xae, 0x22, 0x00, 0x54, 0x9c, 0x1c, 0x35, 0x37, 0x02,
    0x57, 0x4e, 0xbe, 0x3b, 0x18, 0xe8, 0x3b, 0x0d, 0x3d, 0xb2, 0xf4, 0x7d, 0xb0, 0xbf, 0x48, 0xbe,
    0xbf, 0xca, 0x72, 0x9c, 0xd3, 0x7d, 0x24, 0xfd, 0x8e, 0x71, 0x75, 0x77, 0x49, 0x35, 0x81, 0xdd,
    0x32, 0xef, 0x81, 0x27, 0x8a, 0x57, 0x61, 0x31, 0x36, 0x2e, 0xd0, 0xab, 0x46, 0xce, 0x65, 0x53,
    0xed, 0x62, 0x5a, 0x53, 0x2e, 0x02, 0x48, 0x7b, 0xfb, 0x0e, 0x3a, 0x56, 0xa9, 0x19, 0x81, 0x3b,
};

static const uint8_t g_dhPriData3072Two[] = {
    0x05, 0xad, 0x3e, 0x80, 0x1f, 0xe6, 0x7b, 0x23, 0x33, 0x7e, 0x2e, 0xee, 0xd1, 0xfd, 0x0a, 0x33,
    0x3c, 0xff, 0xa7, 0x2f, 0x1b, 0x7e, 0xe9, 0x56, 0x32, 0x55, 0x0b, 0xd0, 0xbd, 0xae, 0x77, 0x24,
    0x5b, 0xc5, 0xeb,
};

static const uint8_t g_dhPubData4096Two[] = {
    0x04, 0x4f, 0x48, 0xc1, 0x03, 0xd7, 0x20, 0xbb, 0xfd, 0xc5, 0x59, 0xdb, 0xed, 0xdd, 0x57, 0xda,
    0xf6, 0x90, 0xe3, 0x39, 0x1f, 0xa9, 0x5d, 0x1d, 0x5f, 0x20, 0x70, 0x95, 0x20, 0xd3, 0xc6, 0x74,
    0xb4, 0x94, 0x13, 0x16, 0x33, 0xfa, 0x8e, 0x25, 0x48, 0xb2, 0xc0, 0xff, 0x5b, 0x8f, 0xba, 0x9c,
    0x2c, 0x62, 0x01, 0xb5, 0x28, 0x0f, 0x4d, 0x55, 0xd6, 0x85, 0x2c, 0xe5, 0xca, 0x34, 0x8b, 0xe9,
    0x6c, 0xfe, 0xf1, 0x8c, 0xc7, 0xbf, 0x6b, 0x70, 0x4d, 0x5c, 0xfd, 0x93, 0x72, 0xf7, 0x3d, 0xda,
    0xa4, 0x3d, 0x7e, 0x13, 0xb3, 0xec, 0x64, 0x05, 0x3c, 0x61, 0x08, 0xe0, 0xbc, 0xa6, 0x85, 0xf8,
    0x87, 0xfd, 0x86, 0xc8, 0x88, 0x65, 0x43, 0x17, 0xc3, 0x56, 0xf3, 0x7a, 0xc8, 0x54, 0x31, 0x4c,
    0x4c, 0xe1, 0x0d, 0x2a, 0x72, 0xf6, 0x69, 0xf1, 0x2f, 0xf0, 0x8b, 0x8d, 0xa4, 0x03, 0x72, 0xca,
    0x94, 0xe6, 0xc0, 0x88, 0x59, 0x77, 0x9b, 0x37, 0x36, 0x92, 0x38, 0xf2, 0x19, 0x3c, 0xaf, 0xde,
    0x6c, 0x4b, 0xb5, 0x89, 0xe2, 0xcb, 0x6c, 0x7d, 0xf0, 0xf6, 0x14, 0x2e, 0x15, 0x54, 0xba, 0xa7,
    0xe7, 0x6a, 0x58, 0x03, 0xdf, 0x09, 0x67, 0xbf, 0x0b, 0x9f, 0xce, 0xdb, 0x4c, 0x12, 0x4d, 0x39,
    0xc0, 0x68, 0x8a, 0x31, 0xd2, 0x22, 0x06, 0xf7, 0xe5, 0x5a, 0x51, 0x80, 0x3e, 0x18, 0x59, 0xbf,
    0xf0, 0xbb, 0x74, 0x50, 0x61, 0x86, 0x3b, 0xd8, 0x54, 0x25, 0xd5, 0x68, 0xa0, 0x41, 0xa5, 0x50,
    0xc5, 0x26, 0xfd, 0xd9, 0xed, 0xa1, 0x9d, 0x56, 0x94, 0xb7, 0x2c, 0x00, 0x9c, 0x3f, 0x4a, 0x84,
    0x2b, 0x1f, 0x3c, 0xb9, 0xc3, 0x84, 0xa0, 0x2d, 0x90, 0x6a, 0x3d, 0xc7, 0xc5, 0x15, 0x30, 0x7b,
    0x95, 0x9c, 0x9e, 0x41, 0x86, 0x5c, 0xb4, 0xe0, 0x0a, 0x6e, 0x31, 0x4d, 0x4e, 0x32, 0xae, 0x10,
    0x0a, 0xb4, 0xd2, 0x7d, 0x2a, 0x55, 0xe9, 0x96, 0x99, 0xca, 0xc0, 0x5a, 0xaf, 0xf4, 0x4e, 0x38,
    0x34, 0x39, 0x80, 0x5b, 0x31, 0x7a, 0x71, 0x24, 0x87, 0x70, 0xcb, 0xa5, 0xac, 0xe0, 0x27, 0x8b,
    0xa8, 0x89, 0x04, 0xbf, 0x68, 0xbe, 0x6c, 0xa4, 0x1e, 0x13, 0x83, 0xb4, 0xa4, 0x05, 0x6e, 0x1f,
    0x8a, 0x9f, 0xea, 0x34, 0x7a, 0x22, 0xc8, 0xcf, 0x21, 0x1b, 0x28, 0xe3, 0x31, 0xc2, 0x1b, 0x96,
    0x81, 0x9e, 0xfd, 0xdd, 0x41, 0x99, 0x94, 0x8b, 0xec, 0x60, 0xe8, 0x5c, 0x84, 0x32, 0x23, 0x60,
    0x47, 0xd3, 0x3c, 0xbb, 0x4a, 0x6d, 0x68, 0x28, 0x50, 0x8d, 0x24, 0x71, 0xcb, 0x4b, 0x0b, 0x1b,
    0x90, 0xb0, 0xd0, 0xd4, 0x8e, 0x53, 0x06, 0x06, 0x6d, 0x7e, 0x62, 0x85, 0xe3, 0x11, 0x8f, 0xe4,
    0xac, 0xec, 0xad, 0x69, 0x39, 0xe2, 0xa1, 0x79, 0xc4, 0xff, 0x28, 0xe0, 0xd2, 0x42, 0x23, 0x17,
    0x98, 0xc3, 0x78, 0xd8, 0xef, 0xff, 0xac, 0xef, 0x67, 0x04, 0x1f, 0x90, 0x4d, 0x1e, 0x92, 0xbb,
    0xa9, 0x48, 0xd3, 0x92, 0xc5, 0xa4, 0x77, 0xd0, 0x41, 0x12, 0x35, 0xbe, 0xc9, 0x71, 0xac, 0x26,
    0x72, 0x2b, 0x8f, 0x6b, 0x4e, 0x45, 0x3d, 0x02, 0x44, 0xd8, 0x4a, 0x18, 0x0f, 0x2c, 0x3c, 0x07,
    0x13, 0x41, 0x39, 0x54, 0x20, 0x6b, 0xff, 0x2f, 0x26, 0x0d, 0x3b, 0x4b, 0x9f, 0xa4, 0x70, 0x93,
    0x33, 0x0d, 0x44, 0xd7, 0x82, 0x78, 0xe4, 0x39, 0x1a, 0x40, 0x17, 0xe7, 0x71, 0xa8, 0x69, 0x43,
    0x65, 0xca, 0x36, 0x93, 0xf8, 0xbf, 0xd2, 0xa3, 0x78, 0x49, 0x48, 0xb9, 0x58, 0xde, 0x66, 0x92,
    0x8c, 0xc7, 0xd5, 0xe3, 0x35, 0x55, 0xff, 0xfb, 0x6a, 0x84, 0x50, 0xa3, 0xda, 0x4b, 0x04, 0x2a,
    0x35, 0x93, 0x4f, 0xd0, 0x92, 0x3e, 0xd9, 0x68, 0xe2, 0x3f, 0x41, 0x54, 0x9a, 0xa7, 0x8a, 0x52,
};

static const uint8_t g_dhPriData4096Two[] = {
    0x12, 0x06, 0x34, 0xb1, 0x4e, 0x21, 0x2b, 0x72, 0x39, 0x1e, 0xba, 0x93, 0xac, 0x08, 0xf6, 0x12,
    0x19, 0x90, 0xae, 0xb6, 0xb7, 0xe7, 0x13, 0xf2, 0xf7, 0xf4, 0x91, 0x9f, 0xcf, 0xc7, 0x6c, 0xc9,
    0xe4, 0xcf, 0xb6, 0x45, 0xa6, 0xa7, 0x72, 0x31, 0xa4,
};

static const uint8_t g_dhX509PubData2048Two[] = {
    0x30, 0x82, 0x02, 0x28, 0x30, 0x82, 0x01, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
    TEST_DATA_01
    0x02, 0x00, 0xe1, 0x03, 0x82, 0x01, 0x05, 0x00, 0x02, 0x82, 0x01, 0x00, 0x6f, 0xe6, 0x00, 0x72,
    0x0e, 0xe2, 0x20, 0x33, 0x05, 0x4a, 0xf4, 0xff, 0x55, 0x27, 0x20, 0x6b, 0xa8, 0x9a, 0x96, 0x0b,
    0xa3, 0x09, 0x4f, 0x5a, 0xaa, 0x49, 0x57, 0xcc, 0x43, 0x94, 0x20, 0x56, 0x6d, 0xf8, 0x32, 0x46,
    0x36, 0x9e, 0x94, 0x70, 0x13, 0xbe, 0x68, 0xfa, 0x2a, 0xdb, 0xd8, 0x33, 0x9f, 0x9d, 0x0b, 0x13,
    0x89, 0xba, 0xd6, 0xe2, 0x68, 0x57, 0x40, 0x60, 0x97, 0xea, 0xde, 0x1f, 0x8c, 0xf7, 0xe1, 0xb7,
    0x73, 0x67, 0x31, 0x26, 0x95, 0x1b, 0x71, 0x24, 0x9e, 0x4d, 0xc6, 0x8b, 0x6f, 0x00, 0x5a, 0x71,
    0xf3, 0x4a, 0xdc, 0xf1, 0x61, 0xab, 0xc5, 0x50, 0xda, 0xc6, 0x5d, 0xa1, 0x23, 0xaa, 0x13, 0x5a,
    0x03, 0xc3, 0x97, 0xe6, 0x92, 0x5a, 0x57, 0x94, 0xa2, 0x2b, 0x52, 0x91, 0xc6, 0x4a, 0x74, 0xe9,
    0x06, 0x6b, 0x71, 0x70, 0x47, 0xe0, 0xf9, 0x2b, 0xa0, 0x15, 0x0c, 0xa7, 0x36, 0xdb, 0xfb, 0x41,
    0x65, 0x3f, 0xfc, 0x27, 0x75, 0xf1, 0x0a, 0xe3, 0x8f, 0x64, 0x27, 0x5c, 0x71, 0x6d, 0x32, 0x1b,
    0x71, 0x2c, 0xbd, 0x89, 0xee, 0xec, 0xa8, 0x0e, 0x8d, 0xaf, 0xef, 0xd8, 0x88, 0xf5, 0x33, 0x3c,
    0x22, 0x2b, 0x96, 0xb6, 0x75, 0x9e, 0x3a, 0x5b, 0xcb, 0x20, 0x84, 0xf5, 0x69, 0x22, 0x52, 0x42,
    0x70, 0x44, 0x61, 0x24, 0x52, 0x2a, 0x3e, 0xa0, 0x1d, 0xa3, 0x85, 0x65, 0x21, 0x91, 0x6f, 0x06,
    0xcb, 0x29, 0x28, 0xaf, 0xf4, 0x17, 0x83, 0x35, 0x6a, 0xe3, 0x14, 0x77, 0x13, 0x3b, 0x97, 0xbd,
    0xd4, 0x3b, 0xb2, 0x8e, 0x58, 0xd5, 0x8d, 0x1f, 0x17, 0x09, 0xe0, 0x94, 0xf1, 0xe7, 0xd3, 0x28,
    0x97, 0x6c, 0xb2, 0x7d, 0xd7, 0x4d, 0x40, 0x04, 0x02, 0x18, 0xb2, 0xa8, 0x63, 0x5a, 0x23, 0x43,
    0xd1, 0xfc, 0xe0, 0xd6, 0x06, 0x40, 0xc0, 0x94, 0xf9, 0x12, 0x5e, 0x20,
};

static const uint8_t g_dhX509PubData3072Two[] = {
    TEST_DATA_02
    0x02, 0x01, 0x13, 0x03, 0x82, 0x01, 0x85, 0x00, 0x02, 0x82, 0x01, 0x80, 0x39, 0xe9, 0x5c, 0xce,
    0x99, 0x1e, 0x57, 0x84, 0xcc, 0x32, 0x68, 0xdf, 0x5f, 0x79, 0x9e, 0x24, 0xf5, 0xbb, 0xc8, 0x4d,
    0xc9, 0xce, 0x2d, 0x99, 0xe9, 0x69, 0xb9, 0xdc, 0xac, 0x82, 0x58, 0xa2, 0x84, 0xa2, 0xc9, 0x34,
    0xc6, 0xef, 0x58, 0xb6, 0xc7, 0xfc, 0xf2, 0xe4, 0x01, 0xed, 0x70, 0xf1, 0x05, 0x6f, 0xd0, 0x26,
    0x55, 0x3f, 0x6a, 0xb0, 0xbd, 0x83, 0x3d, 0x5d, 0x54, 0x6c, 0xed, 0x39, 0x13, 0x44, 0xfb, 0xbf,
    0xef, 0xb3, 0xb1, 0xc3, 0x83, 0x95, 0xb8, 0xce, 0x71, 0x26, 0x4b, 0x2e, 0xdc, 0x4f, 0xe8, 0x4b,
    0x87, 0x7e, 0x6e, 0x01, 0xa9, 0x00, 0x69, 0x7a, 0x52, 0xd2, 0x4b, 0xc2, 0xb9, 0xb4, 0xbe, 0xb6,
    0xea, 0xd8, 0x82, 0x32, 0xea, 0x6e, 0x25, 0xb6, 0x0b, 0x7b, 0x3a, 0x97, 0x61, 0xac, 0x17, 0xba,
    0xd3, 0xf0, 0x05, 0x09, 0x36, 0x95, 0x42, 0x04, 0x6a, 0x1c, 0x43, 0xed, 0x85, 0xf8, 0x67, 0x7f,
    0xe0, 0x2c, 0x37, 0xd8, 0x23, 0x86, 0x23, 0xb0, 0xba, 0x9b, 0x84, 0x9a, 0x30, 0xe3, 0xec, 0x10,
    0x2a, 0x25, 0x33, 0x90, 0x5f, 0x7f, 0xd2, 0xbe, 0xad, 0xea, 0xd3, 0x75, 0xc2, 0xe1, 0x50, 0x62,
    0x5d, 0xd8, 0xb1, 0xbe, 0xc9, 0x3a, 0xd5, 0x33, 0xa1, 0x41, 0x93, 0x33, 0xad, 0xc7, 0x26, 0x00,
    0xb1, 0x18, 0x27, 0x55, 0x65, 0x11, 0xbe, 0x4b, 0x46, 0x8e, 0x3b, 0x82, 0x76, 0x48, 0x52, 0xca,
    0x13, 0x1c, 0xab, 0xa1, 0xa5, 0x3e, 0xca, 0xc5, 0x90, 0x74, 0x35, 0x29, 0x6b, 0x85, 0xa9, 0xd8,
    0xe5, 0x74, 0xeb, 0xff, 0xbf, 0x60, 0x4d, 0x32, 0x0f, 0xc3, 0x2d, 0xba, 0x0d, 0xad, 0xe7, 0xf3,
    0x49, 0x96, 0x93, 0x04, 0x94, 0x2e, 0x4c, 0x84, 0x34, 0x10, 0x47, 0x72, 0x9d, 0xd0, 0x0e, 0xa8,
    0x7b, 0x2f, 0xf2, 0xed, 0xf3, 0xda, 0xa8, 0x69, 0x95, 0xef, 0x0e, 0x20, 0x93, 0x22, 0x3a, 0x4f,
    0x25, 0x7f, 0x1f, 0xd4, 0x0b, 0x23, 0x79, 0x54, 0xeb, 0x87, 0xbd, 0x20, 0x78, 0x1e, 0x36, 0x8e,
    0x42, 0x6f, 0x53, 0xb1, 0xa1, 0x04, 0x82, 0x70, 0x22, 0xf2, 0x32, 0xd6, 0x62, 0xe0, 0x12, 0xa8,
    0x8b, 0x57, 0x08, 0x01, 0xf9, 0x66, 0x06, 0x25, 0xda, 0xe7, 0xd8, 0x4b, 0x69, 0xb4, 0x5f, 0xca,
    0xbe, 0x63, 0x05, 0xae, 0x22, 0x00, 0x54, 0x9c, 0x1c, 0x35, 0x37, 0x02, 0x57, 0x4e, 0xbe, 0x3b,
    0x18, 0xe8, 0x3b, 0x0d, 0x3d, 0xb2, 0xf4, 0x7d, 0xb0, 0xbf, 0x48, 0xbe, 0xbf, 0xca, 0x72, 0x9c,
    0xd3, 0x7d, 0x24, 0xfd, 0x8e, 0x71, 0x75, 0x77, 0x49, 0x35, 0x81, 0xdd, 0x32, 0xef, 0x81, 0x27,
    0x8a, 0x57, 0x61, 0x31, 0x36, 0x2e, 0xd0, 0xab, 0x46, 0xce, 0x65, 0x53, 0xed, 0x62, 0x5a, 0x53,
    0x2e, 0x02, 0x48, 0x7b, 0xfb, 0x0e, 0x3a, 0x56, 0xa9, 0x19, 0x81, 0x3b,
};

static const uint8_t g_dhX509PubData4096Two[] = {
    0x30, 0x82, 0x04, 0x28, 0x30, 0x82, 0x02, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
    TEST_DATA_03
    0x60, 0xd7, 0xf4, 0x68, 0x1d, 0x4f, 0x42, 0xa3, 0xde, 0x39, 0x4d, 0xf4, 0xae, 0x56, 0xed, 0xe7,
    0x63, 0x72, 0xbb, 0x19, 0x0b, 0x07, 0xa7, 0xc8, 0xee, 0x0a, 0x6d, 0x70, 0x9e, 0x02, 0xfc, 0xe1,
    0xcd, 0xf7, 0xe2, 0xec, 0xc0, 0x34, 0x04, 0xcd, 0x28, 0x34, 0x2f, 0x61, 0x91, 0x72, 0xfe, 0x9c,
    0xe9, 0x85, 0x83, 0xff, 0x8e, 0x4f, 0x12, 0x32, 0xee, 0xf2, 0x81, 0x83, 0xc3, 0xfe, 0x3b, 0x1b,
    0x4c, 0x6f, 0xad, 0x73, 0x3b, 0xb5, 0xfc, 0xbc, 0x2e, 0xc2, 0x20, 0x05, 0xc5, 0x8e, 0xf1, 0x83,
    TEST_DATA_04
    0x02, 0x01, 0x45, 0x03, 0x82, 0x02, 0x05, 0x00, 0x02, 0x82, 0x02, 0x00, 0x04, 0x4f, 0x48, 0xc1,
    0x03, 0xd7, 0x20, 0xbb, 0xfd, 0xc5, 0x59, 0xdb, 0xed, 0xdd, 0x57, 0xda, 0xf6, 0x90, 0xe3, 0x39,
    0x1f, 0xa9, 0x5d, 0x1d, 0x5f, 0x20, 0x70, 0x95, 0x20, 0xd3, 0xc6, 0x74, 0xb4, 0x94, 0x13, 0x16,
    0x33, 0xfa, 0x8e, 0x25, 0x48, 0xb2, 0xc0, 0xff, 0x5b, 0x8f, 0xba, 0x9c, 0x2c, 0x62, 0x01, 0xb5,
    0x28, 0x0f, 0x4d, 0x55, 0xd6, 0x85, 0x2c, 0xe5, 0xca, 0x34, 0x8b, 0xe9, 0x6c, 0xfe, 0xf1, 0x8c,
    0xc7, 0xbf, 0x6b, 0x70, 0x4d, 0x5c, 0xfd, 0x93, 0x72, 0xf7, 0x3d, 0xda, 0xa4, 0x3d, 0x7e, 0x13,
    0xb3, 0xec, 0x64, 0x05, 0x3c, 0x61, 0x08, 0xe0, 0xbc, 0xa6, 0x85, 0xf8, 0x87, 0xfd, 0x86, 0xc8,
    0x88, 0x65, 0x43, 0x17, 0xc3, 0x56, 0xf3, 0x7a, 0xc8, 0x54, 0x31, 0x4c, 0x4c, 0xe1, 0x0d, 0x2a,
    0x72, 0xf6, 0x69, 0xf1, 0x2f, 0xf0, 0x8b, 0x8d, 0xa4, 0x03, 0x72, 0xca, 0x94, 0xe6, 0xc0, 0x88,
    0x59, 0x77, 0x9b, 0x37, 0x36, 0x92, 0x38, 0xf2, 0x19, 0x3c, 0xaf, 0xde, 0x6c, 0x4b, 0xb5, 0x89,
    0xe2, 0xcb, 0x6c, 0x7d, 0xf0, 0xf6, 0x14, 0x2e, 0x15, 0x54, 0xba, 0xa7, 0xe7, 0x6a, 0x58, 0x03,
    0xdf, 0x09, 0x67, 0xbf, 0x0b, 0x9f, 0xce, 0xdb, 0x4c, 0x12, 0x4d, 0x39, 0xc0, 0x68, 0x8a, 0x31,
    0xd2, 0x22, 0x06, 0xf7, 0xe5, 0x5a, 0x51, 0x80, 0x3e, 0x18, 0x59, 0xbf, 0xf0, 0xbb, 0x74, 0x50,
    0x61, 0x86, 0x3b, 0xd8, 0x54, 0x25, 0xd5, 0x68, 0xa0, 0x41, 0xa5, 0x50, 0xc5, 0x26, 0xfd, 0xd9,
    0xed, 0xa1, 0x9d, 0x56, 0x94, 0xb7, 0x2c, 0x00, 0x9c, 0x3f, 0x4a, 0x84, 0x2b, 0x1f, 0x3c, 0xb9,
    0xc3, 0x84, 0xa0, 0x2d, 0x90, 0x6a, 0x3d, 0xc7, 0xc5, 0x15, 0x30, 0x7b, 0x95, 0x9c, 0x9e, 0x41,
    0x86, 0x5c, 0xb4, 0xe0, 0x0a, 0x6e, 0x31, 0x4d, 0x4e, 0x32, 0xae, 0x10, 0x0a, 0xb4, 0xd2, 0x7d,
    0x2a, 0x55, 0xe9, 0x96, 0x99, 0xca, 0xc0, 0x5a, 0xaf, 0xf4, 0x4e, 0x38, 0x34, 0x39, 0x80, 0x5b,
    0x31, 0x7a, 0x71, 0x24, 0x87, 0x70, 0xcb, 0xa5, 0xac, 0xe0, 0x27, 0x8b, 0xa8, 0x89, 0x04, 0xbf,
    0x68, 0xbe, 0x6c, 0xa4, 0x1e, 0x13, 0x83, 0xb4, 0xa4, 0x05, 0x6e, 0x1f, 0x8a, 0x9f, 0xea, 0x34,
    0x7a, 0x22, 0xc8, 0xcf, 0x21, 0x1b, 0x28, 0xe3, 0x31, 0xc2, 0x1b, 0x96, 0x81, 0x9e, 0xfd, 0xdd,
    0x41, 0x99, 0x94, 0x8b, 0xec, 0x60, 0xe8, 0x5c, 0x84, 0x32, 0x23, 0x60, 0x47, 0xd3, 0x3c, 0xbb,
    0x4a, 0x6d, 0x68, 0x28, 0x50, 0x8d, 0x24, 0x71, 0xcb, 0x4b, 0x0b, 0x1b, 0x90, 0xb0, 0xd0, 0xd4,
    0x8e, 0x53, 0x06, 0x06, 0x6d, 0x7e, 0x62, 0x85, 0xe3, 0x11, 0x8f, 0xe4, 0xac, 0xec, 0xad, 0x69,
    0x39, 0xe2, 0xa1, 0x79, 0xc4, 0xff, 0x28, 0xe0, 0xd2, 0x42, 0x23, 0x17, 0x98, 0xc3, 0x78, 0xd8,
    0xef, 0xff, 0xac, 0xef, 0x67, 0x04, 0x1f, 0x90, 0x4d, 0x1e, 0x92, 0xbb, 0xa9, 0x48, 0xd3, 0x92,
    0xc5, 0xa4, 0x77, 0xd0, 0x41, 0x12, 0x35, 0xbe, 0xc9, 0x71, 0xac, 0x26, 0x72, 0x2b, 0x8f, 0x6b,
    0x4e, 0x45, 0x3d, 0x02, 0x44, 0xd8, 0x4a, 0x18, 0x0f, 0x2c, 0x3c, 0x07, 0x13, 0x41, 0x39, 0x54,
    0x20, 0x6b, 0xff, 0x2f, 0x26, 0x0d, 0x3b, 0x4b, 0x9f, 0xa4, 0x70, 0x93, 0x33, 0x0d, 0x44, 0xd7,
    0x82, 0x78, 0xe4, 0x39, 0x1a, 0x40, 0x17, 0xe7, 0x71, 0xa8, 0x69, 0x43, 0x65, 0xca, 0x36, 0x93,
    0xf8, 0xbf, 0xd2, 0xa3, 0x78, 0x49, 0x48, 0xb9, 0x58, 0xde, 0x66, 0x92, 0x8c, 0xc7, 0xd5, 0xe3,
    0x35, 0x55, 0xff, 0xfb, 0x6a, 0x84, 0x50, 0xa3, 0xda, 0x4b, 0x04, 0x2a, 0x35, 0x93, 0x4f, 0xd0,
    0x92, 0x3e, 0xd9, 0x68, 0xe2, 0x3f, 0x41, 0x54, 0x9a, 0xa7, 0x8a, 0x52,
};

static const uint8_t g_x25519PubDataOne[] = {
    0x9c, 0xf6, 0x7a, 0x8d, 0xce, 0xc2, 0x7f, 0xa7, 0xd9, 0xfd, 0xf1, 0xad, 0xac, 0xf0, 0xb3, 0x8c,
    0xe8, 0x16, 0xa2, 0x65, 0xcc, 0x18, 0x55, 0x60, 0xcd, 0x2f, 0xf5, 0xe5, 0x72, 0xc9, 0x3c, 0x54,
};

static const uint8_t g_x25519PriDataOne[] = {
    0x20, 0xd5, 0xbb, 0x54, 0x6f, 0x1f, 0x00, 0x30, 0x4e, 0x33, 0x38, 0xb9, 0x8e, 0x6a, 0xdf, 0xad,
    0x33, 0x6f, 0x51, 0x23, 0xff, 0x4d, 0x95, 0x26, 0xdc, 0xb0, 0x74, 0xb2, 0x5c, 0x7e, 0x85, 0x6c,
};

static const uint8_t g_x25519PubDataTwo[] = {
    0xdc, 0xa3, 0xe3, 0xec, 0xa3, 0x99, 0x06, 0x59, 0xc8, 0x7f, 0xb8, 0x6a, 0x82, 0xe3, 0x35, 0xfb,
    0xa8, 0x8e, 0x0e, 0x10, 0x71, 0x65, 0x22, 0x98, 0x8a, 0x75, 0x94, 0xeb, 0x01, 0x32, 0xa0, 0x41,
};

static const uint8_t g_x25519PriDataTwo[] = {
    0x98, 0x69, 0x6b, 0xf0, 0x9a, 0xdc, 0x0c, 0x80, 0x39, 0xe7, 0x1c, 0xcf, 0xf1, 0xb1, 0xcb, 0xdd,
    0x9c, 0xfa, 0xbe, 0xfc, 0x27, 0x72, 0xa6, 0xd3, 0x08, 0x09, 0x91, 0x72, 0xb2, 0x8d, 0x23, 0x4a,
};

static const uint8_t g_eccXData256One[] = {
    0xa5, 0xb8, 0xa3, 0x78, 0x1d, 0x6d, 0x76, 0xe0, 0xb3, 0xf5, 0x6f, 0x43, 0x9d, 0xcf, 0x60, 0xf6,
    0x0b, 0x3f, 0x64, 0x45, 0xa8, 0x3f, 0x1a, 0x96, 0xf1, 0xa1, 0xa4, 0x5d, 0x3e, 0x2c, 0x3f, 0x13,
};

static const uint8_t g_eccYData256One[] = {
    0xd7, 0x81, 0xf7, 0x2a, 0xb5, 0x8d, 0x19, 0x3d, 0x9b, 0x96, 0xc7, 0x6a, 0x10, 0xf0, 0xaa, 0xbc,
    0x91, 0x6f, 0x4d, 0xa7, 0x09, 0xb3, 0x57, 0x88, 0x19, 0x6f, 0x00, 0x4b, 0xad, 0xee, 0x34, 0x35,
};

static const uint8_t g_eccZData256One[] = {
    0xfb, 0x8b, 0x9f, 0x12, 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63, 0x2a, 0x7c, 0x86, 0xba, 0xca,
    0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa, 0x77, 0xbc, 0x71, 0xe3, 0x0f, 0x0f, 0x9e, 0x3c, 0xe5, 0xf9,
};

static const uint8_t g_eccPubData256One[] = {
    0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a,
    0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xa5, 0xb8, 0xa3, 0x78, 0x1d,
    0x6d, 0x76, 0xe0, 0xb3, 0xf5, 0x6f, 0x43, 0x9d, 0xcf, 0x60, 0xf6, 0x0b, 0x3f, 0x64, 0x45, 0xa8,
    0x3f, 0x1a, 0x96, 0xf1, 0xa1, 0xa4, 0x5d, 0x3e, 0x2c, 0x3f, 0x13, 0xd7, 0x81, 0xf7, 0x2a, 0xb5,
    0x8d, 0x19, 0x3d, 0x9b, 0x96, 0xc7, 0x6a, 0x10, 0xf0, 0xaa, 0xbc, 0x91, 0x6f, 0x4d, 0xa7, 0x09,
    0xb3, 0x57, 0x88, 0x19, 0x6f, 0x00, 0x4b, 0xad, 0xee, 0x34, 0x35,
};

static const uint8_t g_eccXData256Two[] = {
    0xc0, 0xfe, 0x1c, 0x67, 0xde, 0x86, 0x0e, 0xfb, 0xaf, 0xb5, 0x85, 0x52, 0xb4, 0x0e, 0x1f, 0x6c,
    0x6c, 0xaa, 0xc5, 0xd9, 0xd2, 0x4d, 0xb0, 0x8a, 0x72, 0x24, 0xa1, 0x99, 0xaf, 0xfc, 0x3e, 0x55,
};

static const uint8_t g_eccYData256Two[] = {
    0x5a, 0xac, 0x99, 0x3d, 0xe8, 0x34, 0x72, 0xb9, 0x47, 0x9c, 0xa6, 0xd8, 0xfb, 0x00, 0xa0, 0x1f,
    0x9f, 0x7a, 0x41, 0xe5, 0x44, 0x3e, 0xb2, 0x76, 0x08, 0xa2, 0xbd, 0xe9, 0x41, 0xd5, 0x2b, 0x9e,
};

static const uint8_t g_eccZData256Two[] = {
    0x6d, 0x9d, 0x29, 0x3a, 0x54, 0x94, 0x3c, 0xc5, 0x23, 0xaf, 0x98, 0x4b, 0x5c, 0x48, 0x50, 0xcd,
    0x12, 0x3d, 0x4d, 0x82, 0xb1, 0x26, 0x8e, 0xa2, 0xed, 0xf0, 0xf4, 0x59, 0x7c, 0x9b, 0xeb, 0xd0,
};

static const uint8_t g_eccPubData256Two[] = {
    0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a,
    0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xc0, 0xfe, 0x1c, 0x67, 0xde,
    0x86, 0x0e, 0xfb, 0xaf, 0xb5, 0x85, 0x52, 0xb4, 0x0e, 0x1f, 0x6c, 0x6c, 0xaa, 0xc5, 0xd9, 0xd2,
    0x4d, 0xb0, 0x8a, 0x72, 0x24, 0xa1, 0x99, 0xaf, 0xfc, 0x3e, 0x55, 0x5a, 0xac, 0x99, 0x3d, 0xe8,
    0x34, 0x72, 0xb9, 0x47, 0x9c, 0xa6, 0xd8, 0xfb, 0x00, 0xa0, 0x1f, 0x9f, 0x7a, 0x41, 0xe5, 0x44,
    0x3e, 0xb2, 0x76, 0x08, 0xa2, 0xbd, 0xe9, 0x41, 0xd5, 0x2b, 0x9e,
};

static struct HksParam g_importKeyParams[] = {
    { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_ECC },
    { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_AGREE },
    { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_ECC_KEY_SIZE_256 },
    { .tag = HKS_TAG_IMPORT_KEY_TYPE, .uint32Param = HKS_KEY_TYPE_PRIVATE_KEY },
    { .tag = HKS_TAG_DIGEST, .uint32Param = HKS_DIGEST_SHA256 },
};

static struct HksParam g_initOpParams[] = {
    { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_ECDH },
    { .tag = HKS_TAG_PURPOSE, .uint32Param = HKS_KEY_PURPOSE_AGREE },
    { .tag = HKS_TAG_KEY_SIZE, .uint32Param = HKS_ECC_KEY_SIZE_256 },
};

static struct HksParam g_updateParams[] = {
    { .tag = HKS_TAG_ALGORITHM, .uint32Param = HKS_ALG_ECDH },
};

static struct HksParam g_finishParams[] = {
    { .tag = HKS_TAG_KEY_STORAGE_FLAG, .uint32Param = HKS_STORAGE_TEMP },
};

struct TestImportKeyData {
    struct HksBlob x509PublicKey;
    struct HksBlob publicOrXData;
    struct HksBlob privateOrYData;
    struct HksBlob zData;
};

static void ModifyImportParams(uint32_t alg, uint32_t keySize, uint32_t importType)
{
    g_importKeyParams[TAG_ALG_ID].uint32Param = alg;
    g_importKeyParams[TAG_KEY_SIZE_ID].uint32Param = keySize;
    g_importKeyParams[TAG_IMPOT_TYPE_ID].uint32Param = importType;
}

static void ModifyinitOpParams(uint32_t alg, uint32_t keySize)
{
    g_initOpParams[TAG_ALG_ID].uint32Param = alg;
    g_initOpParams[TAG_KEY_SIZE_ID].uint32Param = keySize;
}

static int32_t CopyKey(const uint8_t *key, uint32_t size, struct HksBlob *outKey)
{
    uint8_t *outData = (uint8_t *)HksMalloc(size);
    if (outData == nullptr) {
        return HKS_ERROR_MALLOC_FAIL;
    }

    (void)memcpy_s(outData, size, key, size);
    outKey->data = outData;
    outKey->size = size;

    return HKS_SUCCESS;
}

static int32_t CopyToInner(struct TestImportKeyData *key, uint32_t importType, struct HksBlob *outKey)
{
    if (importType == HKS_KEY_TYPE_PRIVATE_KEY) {
        return CopyKey(key->privateOrYData.data, key->privateOrYData.size, outKey);
    } else {
        return CopyKey(key->publicOrXData.data, key->publicOrXData.size, outKey);
    }
}

static int32_t ConstructCurve25519Key(struct TestImportKeyData *key,
    uint32_t alg, uint32_t keySize, uint32_t importType, struct HksBlob *outKey)
{
    if ((importType == HKS_KEY_TYPE_PRIVATE_KEY) || (importType == HKS_KEY_TYPE_PUBLIC_KEY)) {
        return CopyToInner(key, importType, outKey);
    }

    struct HksKeyMaterial25519 material;
    material.keyAlg = (enum HksKeyAlg)alg;
    material.keySize = keySize;
    material.pubKeySize = key->publicOrXData.size;
    material.priKeySize = key->privateOrYData.size;
    material.reserved = 0;

    uint32_t size = sizeof(material) + material.pubKeySize + material.priKeySize;
    uint8_t *dataTest = (uint8_t *) HksMalloc(size);
    if (dataTest == nullptr) {
        return HKS_ERROR_MALLOC_FAIL;
    }

    // copy struct material
    if (memcpy_s(dataTest, size, &material, sizeof(material)) != EOK) {
        HKS_FREE(dataTest);
        return HKS_ERROR_BAD_STATE;
    }

    uint32_t offset = sizeof(material);
    // copy publicData
    if (memcpy_s(dataTest + offset, size - offset, key->publicOrXData.data, key->publicOrXData.size) != EOK) {
        HKS_FREE(dataTest);
        return HKS_ERROR_BAD_STATE;
    }
    offset += material.pubKeySize;

    // copy privateData
    if (memcpy_s(dataTest + offset, size - offset, key->privateOrYData.data, key->privateOrYData.size) != EOK) {
        HKS_FREE(dataTest);
        return HKS_ERROR_BAD_STATE;
    }

    outKey->data = dataTest;
    outKey->size = size;
    return HKS_SUCCESS;
}

static int32_t ConstructEccKey(struct TestImportKeyData *key,
    uint32_t keySize, uint32_t importType, struct HksBlob *outKey)
{
    if (importType == HKS_KEY_TYPE_PUBLIC_KEY) {
        return CopyKey(key->x509PublicKey.data, key->x509PublicKey.size, outKey);
    }

    bool isPriKey = (importType == HKS_KEY_TYPE_PRIVATE_KEY) ? true : false;

    struct HksKeyMaterialEcc material;
    material.keyAlg = HKS_ALG_ECC;
    material.keySize = keySize;
    material.xSize = isPriKey ? 0 : key->publicOrXData.size;
    material.ySize = isPriKey ? 0 : key->privateOrYData.size;
    material.zSize = key->zData.size;

    uint32_t size = sizeof(material) + material.xSize + material.ySize + material.zSize;
    uint8_t *data = (uint8_t *)HksMalloc(size);
    if (data == nullptr) {
        return HKS_ERROR_MALLOC_FAIL;
    }

    // copy struct material
    if (memcpy_s(data, size, &material, sizeof(material)) != EOK) {
        HKS_FREE(data);
        return HKS_ERROR_BAD_STATE;
    }

    uint32_t offset = sizeof(material);
    if (!isPriKey) {
        // copy xData
        if (memcpy_s(data + offset, size - offset, key->publicOrXData.data, key->publicOrXData.size) != EOK) {
            HKS_FREE(data);
            return HKS_ERROR_BAD_STATE;
        }

        offset += material.xSize;
        // copy yData
        if (memcpy_s(data + offset, size - offset, key->privateOrYData.data, key->privateOrYData.size) != EOK) {
            HKS_FREE(data);
            return HKS_ERROR_BAD_STATE;
        }
        offset += material.ySize;
    }

    // copy zData
    if (memcpy_s(data + offset, size - offset, key->zData.data, key->zData.size) != EOK) {
        HKS_FREE(data);
        return HKS_ERROR_BAD_STATE;
    }

    outKey->data = data;
    outKey->size = size;
    return HKS_SUCCESS;
}

static int32_t ConstructDhKey(struct TestImportKeyData *key,
    uint32_t keySize, uint32_t importType, struct HksBlob *outKey)
{
    if (importType == HKS_KEY_TYPE_PUBLIC_KEY) {
        return CopyKey(key->x509PublicKey.data, key->x509PublicKey.size, outKey);
    }

    bool isPriKey = (importType == HKS_KEY_TYPE_PRIVATE_KEY) ? true : false;

    struct HksKeyMaterialDh material;
    material.keyAlg = HKS_ALG_DH;
    material.keySize = keySize;
    material.pubKeySize = isPriKey ? 0 : key->publicOrXData.size;
    material.priKeySize = key->privateOrYData.size;
    material.reserved = 0;

    uint32_t size = sizeof(material) + material.pubKeySize + material.priKeySize;
    uint8_t *data = (uint8_t *)HksMalloc(size);
    if (data == nullptr) {
        return HKS_ERROR_MALLOC_FAIL;
    }

    // copy struct material
    if (memcpy_s(data, size, &material, sizeof(material)) != EOK) {
        HKS_FREE(data);
        return HKS_ERROR_BAD_STATE;
    }

    uint32_t offset = sizeof(material);
    if (!isPriKey) {
        // copy publicData
        if (memcpy_s(data + offset, size - offset, key->publicOrXData.data, key->publicOrXData.size) != EOK) {
            HKS_FREE(data);
            return HKS_ERROR_BAD_STATE;
        }
        offset += material.pubKeySize;
    }

    // copy privateData
    if (memcpy_s(data + offset, size - offset, key->privateOrYData.data, key->privateOrYData.size) != EOK) {
        HKS_FREE(data);
        return HKS_ERROR_BAD_STATE;
    }

    outKey->data = data;
    outKey->size = size;
    return HKS_SUCCESS;
}

static int32_t ConstructImportedCurve25519Key(uint32_t id, uint32_t alg, uint32_t keySize, uint32_t importType,
    struct HksBlob *outKey)
{
    struct TestImportKeyData key;
    (void)memset_s(&key, sizeof(key), 0, sizeof(key));
    if (id == 0) {
        key.privateOrYData.data = (uint8_t *)g_x25519PriDataOne;
        key.privateOrYData.size = sizeof(g_x25519PriDataOne);
        key.publicOrXData.data = (uint8_t *)g_x25519PubDataOne;
        key.publicOrXData.size = sizeof(g_x25519PubDataOne);
    } else {
        key.privateOrYData.data = (uint8_t *)g_x25519PriDataTwo;
        key.privateOrYData.size = sizeof(g_x25519PriDataTwo);
        key.publicOrXData.data = (uint8_t *)g_x25519PubDataTwo;
        key.publicOrXData.size = sizeof(g_x25519PubDataTwo);
    }

    return ConstructCurve25519Key(&key, alg, keySize, importType, outKey);
}

static int32_t ConstructImportedEccKey(uint32_t id, uint32_t keySize, uint32_t importType,
    struct HksBlob *outKey)
{
    struct TestImportKeyData key;
    (void)memset_s(&key, sizeof(key), 0, sizeof(key));
    if (id == 0) {
        key.privateOrYData.data = (uint8_t *)g_eccXData256One;
        key.privateOrYData.size = sizeof(g_eccXData256One);
        key.publicOrXData.data = (uint8_t *)g_eccYData256One;
        key.publicOrXData.size = sizeof(g_eccYData256One);
        key.zData.data = (uint8_t *)g_eccZData256One;
        key.zData.size = sizeof(g_eccZData256One);
        key.x509PublicKey.data = (uint8_t *)g_eccPubData256One;
        key.x509PublicKey.size = sizeof(g_eccPubData256One);
    } else {
        key.privateOrYData.data = (uint8_t *)g_eccXData256Two;
        key.privateOrYData.size = sizeof(g_eccXData256Two);
        key.publicOrXData.data = (uint8_t *)g_eccYData256Two;
        key.publicOrXData.size = sizeof(g_eccYData256Two);
        key.zData.data = (uint8_t *)g_eccZData256Two;
        key.zData.size = sizeof(g_eccZData256Two);
        key.x509PublicKey.data = (uint8_t *)g_eccPubData256Two;
        key.x509PublicKey.size = sizeof(g_eccPubData256Two);
    }

    return ConstructEccKey(&key, keySize, importType, outKey);
}

static int32_t ConstructDhKeyStructOne(uint32_t keySize, struct TestImportKeyData *key)
{
    switch (keySize) {
        case HKS_DH_KEY_SIZE_2048:
            key->publicOrXData.data = (uint8_t *)g_dhPubData2048One;
            key->publicOrXData.size = sizeof(g_dhPubData2048One);
            key->privateOrYData.data = (uint8_t *)g_dhPriData2048One;
            key->privateOrYData.size = sizeof(g_dhPriData2048One);
            key->x509PublicKey.data = (uint8_t *)g_dhX509PubData2048One;
            key->x509PublicKey.size = sizeof(g_dhX509PubData2048One);
            break;
        case HKS_DH_KEY_SIZE_3072:
            key->publicOrXData.data = (uint8_t *)g_dhPubData3072One;
            key->publicOrXData.size = sizeof(g_dhPubData3072One);
            key->privateOrYData.data = (uint8_t *)g_dhPriData3072One;
            key->privateOrYData.size = sizeof(g_dhPriData3072One);
            key->x509PublicKey.data = (uint8_t *)g_dhX509PubData3072One;
            key->x509PublicKey.size = sizeof(g_dhX509PubData3072One);
            break;
        case HKS_DH_KEY_SIZE_4096:
            key->publicOrXData.data = (uint8_t *)g_dhPubData4096One;
            key->publicOrXData.size = sizeof(g_dhPubData4096One);
            key->privateOrYData.data = (uint8_t *)g_dhPriData4096One;
            key->privateOrYData.size = sizeof(g_dhPriData4096One);
            key->x509PublicKey.data = (uint8_t *)g_dhX509PubData4096One;
            key->x509PublicKey.size = sizeof(g_dhX509PubData4096One);
            break;
        default:
            return HKS_ERROR_INVALID_KEY_SIZE;
    }
    return HKS_SUCCESS;
}

static int32_t ConstructDhKeyStructTwo(uint32_t keySize, struct TestImportKeyData *key)
{
    switch (keySize) {
        case HKS_DH_KEY_SIZE_2048:
            key->publicOrXData.data = (uint8_t *)g_dhPubData2048Two;
            key->publicOrXData.size = sizeof(g_dhPubData2048Two);
            key->privateOrYData.data = (uint8_t *)g_dhPriData2048Two;
            key->privateOrYData.size = sizeof(g_dhPriData2048Two);
            key->x509PublicKey.data = (uint8_t *)g_dhX509PubData2048Two;
            key->x509PublicKey.size = sizeof(g_dhX509PubData2048Two);
            break;
        case HKS_DH_KEY_SIZE_3072:
            key->publicOrXData.data = (uint8_t *)g_dhPubData3072Two;
            key->publicOrXData.size = sizeof(g_dhPubData3072Two);
            key->privateOrYData.data = (uint8_t *)g_dhPriData3072Two;
            key->privateOrYData.size = sizeof(g_dhPriData3072Two);
            key->x509PublicKey.data = (uint8_t *)g_dhX509PubData3072Two;
            key->x509PublicKey.size = sizeof(g_dhX509PubData3072Two);
            break;
        case HKS_DH_KEY_SIZE_4096:
            key->publicOrXData.data = (uint8_t *)g_dhPubData4096Two;
            key->publicOrXData.size = sizeof(g_dhPubData4096Two);
            key->privateOrYData.data = (uint8_t *)g_dhPriData4096Two;
            key->privateOrYData.size = sizeof(g_dhPriData4096Two);
            key->x509PublicKey.data = (uint8_t *)g_dhX509PubData4096Two;
            key->x509PublicKey.size = sizeof(g_dhX509PubData4096Two);
            break;
        default:
            return HKS_ERROR_INVALID_KEY_SIZE;
    }
    return HKS_SUCCESS;
}

static int32_t ConstructImportedDhKey(uint32_t id, uint32_t keySize, uint32_t importType,
    struct HksBlob *outKey)
{
    struct TestImportKeyData key;
    (void)memset_s(&key, sizeof(key), 0, sizeof(key));
    int32_t ret;
    if (id == 0) {
        ret = ConstructDhKeyStructOne(keySize, &key);
    } else {
        ret = ConstructDhKeyStructTwo(keySize, &key);
    }
    if (ret != HKS_SUCCESS) {
        return ret;
    }

    return ConstructDhKey(&key, keySize, importType, outKey);
}

static int32_t ConstructImportedKey(uint32_t id, uint32_t alg, uint32_t keySize, uint32_t importType,
    struct HksBlob *outKey)
{
    if (alg == HKS_ALG_X25519) {
        return ConstructImportedCurve25519Key(id, alg, keySize, importType, outKey);
    } else if (alg == HKS_ALG_DH) {
        return ConstructImportedDhKey(id, keySize, importType, outKey);
    } else if (alg == HKS_ALG_ECC) {
        return ConstructImportedEccKey(id, keySize, importType, outKey);
    } else {
        return HKS_ERROR_INVALID_ALGORITHM;
    }
}

static int32_t ImportKey(const struct HksBlob *keyAlias, uint32_t id,
    const struct HksParam *params, uint32_t paramCount)
{
    struct HksParamSet *paramSet = nullptr;
    int32_t ret = InitParamSet(&paramSet, params, paramCount);
    if (ret != HKS_SUCCESS) {
        return ret;
    }

    struct HksBlob key = { 0, nullptr };

    // The caller guarantees that the access will not cross the border
    ret = ConstructImportedKey(id, params[TAG_ALG_ID].uint32Param, params[TAG_KEY_SIZE_ID].uint32Param,
        params[TAG_IMPOT_TYPE_ID].uint32Param, &key);
    if (ret != HKS_SUCCESS) {
        HksFreeParamSet(&paramSet);
        return ret;
    }

    ret = HksImportKeyForDe(keyAlias, paramSet, &key);
    HKS_FREE(key.data);
    HksFreeParamSet(&paramSet);
    return ret;
}

static int32_t ConstructAgreePubKeyX25519(uint32_t id, struct HksBlob *publicKey)
{
    if (id == 0) {
        return CopyKey(g_x25519PubDataOne, sizeof(g_x25519PubDataOne), publicKey);
    }
    return CopyKey(g_x25519PubDataTwo, sizeof(g_x25519PubDataTwo), publicKey);
}

static int32_t ConstructAgreePubKeyEcc(uint32_t id, struct HksBlob *publicKey)
{
    if (id == 0) {
        return CopyKey(g_eccPubData256One, sizeof(g_eccPubData256One), publicKey);
    }
    return CopyKey(g_eccPubData256Two, sizeof(g_eccPubData256Two), publicKey);
}

static int32_t ConstructAgreePubKeyDh(uint32_t id, uint32_t keySize, struct HksBlob *publicKey)
{
    if (id == 0) {
        switch (keySize) {
            case HKS_DH_KEY_SIZE_2048:
                return CopyKey(g_dhX509PubData2048One, sizeof(g_dhX509PubData2048One), publicKey);
            case HKS_DH_KEY_SIZE_3072:
                return CopyKey(g_dhX509PubData3072One, sizeof(g_dhX509PubData3072One), publicKey);
            case HKS_DH_KEY_SIZE_4096:
                return CopyKey(g_dhX509PubData4096One, sizeof(g_dhX509PubData4096One), publicKey);
            default:
                return HKS_ERROR_INVALID_KEY_SIZE;
        }
    }

    switch (keySize) {
        case HKS_DH_KEY_SIZE_2048:
            return CopyKey(g_dhX509PubData2048Two, sizeof(g_dhX509PubData2048Two), publicKey);
        case HKS_DH_KEY_SIZE_3072:
            return CopyKey(g_dhX509PubData3072Two, sizeof(g_dhX509PubData3072Two), publicKey);
        case HKS_DH_KEY_SIZE_4096:
            return CopyKey(g_dhX509PubData4096Two, sizeof(g_dhX509PubData4096Two), publicKey);
        default:
            return HKS_ERROR_INVALID_KEY_SIZE;
    }
}

static int32_t ConstructAgreePubKey(uint32_t alg, uint32_t keySize, uint32_t id, struct HksBlob *publicKey)
{
    if (alg == HKS_ALG_X25519) {
        return ConstructAgreePubKeyX25519(id, publicKey);
    } else if (alg == HKS_ALG_ECC) {
        return ConstructAgreePubKeyEcc(id, publicKey);
    } else if (alg == HKS_ALG_DH) {
        return ConstructAgreePubKeyDh(id, keySize, publicKey);
    }
    return HKS_ERROR_INVALID_ALGORITHM;
}

static int32_t ConstructParamSets(    struct HksParamSet **initParamSet,
    struct HksParamSet **updateParamSet, struct HksParamSet **finishParamSet)
{
    int32_t ret = InitParamSet(initParamSet, g_initOpParams, sizeof(g_initOpParams) / sizeof(struct HksParam));
    if (ret != HKS_SUCCESS) {
        return ret;
    }

    ret = InitParamSet(updateParamSet, g_updateParams, sizeof(g_updateParams) / sizeof(struct HksParam));
    if (ret != HKS_SUCCESS) {
        HksFreeParamSet(initParamSet);
        return ret;
    }

    ret = InitParamSet(finishParamSet, g_finishParams, sizeof(g_finishParams) / sizeof(struct HksParam));
    if (ret != HKS_SUCCESS) {
        HksFreeParamSet(initParamSet);
        HksFreeParamSet(updateParamSet);
    }
    return ret;
}

static int32_t TestAgree(const struct HksBlob *keyAlias, const struct HksBlob *peerPubKey, struct HksBlob *agreeKey)
{
    struct HksParamSet *initParamSet = nullptr;
    struct HksParamSet *updateParamSet = nullptr;
    struct HksParamSet *finishParamSet = nullptr;
    int32_t ret = ConstructParamSets(&initParamSet, &updateParamSet, &finishParamSet);
    if (ret != HKS_SUCCESS) {
        return ret;
    }

    do {
        uint64_t handleValue = 0;
        struct HksBlob handle = { sizeof(uint64_t), (uint8_t *)&handleValue };
        ret = HksInitForDe(keyAlias, initParamSet, &handle, nullptr);
        if (ret != HKS_SUCCESS) {
            break;
        }

        struct HksBlob tmpBlob = { 0, nullptr };
        ret = HksUpdateForDe(&handle, updateParamSet, peerPubKey, &tmpBlob);
        if (ret != HKS_SUCCESS) {
            break;
        }

        uint8_t tempIn[LENGTH_MAX] = {0};
        struct HksBlob tmpInBlob = { 0, tempIn };
        ret = HksFinishForDe(&handle, finishParamSet, &tmpInBlob, agreeKey);
    } while (0);

    HksFreeParamSet(&initParamSet);
    HksFreeParamSet(&updateParamSet);
    HksFreeParamSet(&finishParamSet);
    return ret;
}

static int32_t TestAgreeOp(const struct HksBlob *keyAlias1, const struct HksBlob *keyAlias2,
    uint32_t alg, uint32_t keySize)
{
    struct HksBlob pubKey1 = { 0, nullptr };
    struct HksBlob pubKey2 = { 0, nullptr };
    int32_t ret = ConstructAgreePubKey(alg, keySize, 0, &pubKey1);
    if (ret != HKS_SUCCESS) {
        return ret;
    }
    ret = ConstructAgreePubKey(alg, keySize, 1, &pubKey2);
    if (ret != HKS_SUCCESS) {
        HKS_FREE(pubKey1.data);
        return ret;
    }

    ModifyinitOpParams((alg == HKS_ALG_ECC) ? HKS_ALG_ECDH : alg, keySize);

    uint8_t agreeBuf1[LENGTH_MAX] = {0};
    struct HksBlob agreeKey1 = { LENGTH_MAX, agreeBuf1 };
    uint8_t agreeBuf2[LENGTH_MAX] = {0};
    struct HksBlob agreeKey2 = { LENGTH_MAX, agreeBuf2 };

    do {
        ret = TestAgree(keyAlias1, &pubKey2, &agreeKey1);
        if (ret != HKS_SUCCESS) {
            break;
        }

        ret = TestAgree(keyAlias2, &pubKey1, &agreeKey2);
        if (ret != HKS_SUCCESS) {
            break;
        }

        ret = TestCmpKeyAliasHash(&agreeKey1, &agreeKey2);
    } while (0);

    HKS_FREE(pubKey1.data);
    HKS_FREE(pubKey2.data);
    return ret;
}

static void TestImportKey(uint32_t alg, uint32_t keySize, uint32_t importType)
{
    uint8_t alias1[] = "import_key1";
    struct HksBlob keyAlias1 = { sizeof(alias1), alias1 };
    ModifyImportParams(alg, keySize, importType);
    int32_t ret = ImportKey(&keyAlias1, 0, g_importKeyParams, sizeof(g_importKeyParams) / sizeof(struct HksParam));
    EXPECT_EQ(ret, HKS_SUCCESS) << "import key 1 failed:" << importType;

    uint8_t alias2[] = "import_key2";
    struct HksBlob keyAlias2 = { sizeof(alias2), alias2 };
    ret = ImportKey(&keyAlias2, 1, g_importKeyParams, sizeof(g_importKeyParams) / sizeof(struct HksParam));
    EXPECT_EQ(ret, HKS_SUCCESS) << "import key 2 failed:" << importType;

    if (importType != HKS_KEY_TYPE_PUBLIC_KEY) {
        ret = TestAgreeOp(&keyAlias1, &keyAlias2, alg, keySize);
        EXPECT_EQ(ret, HKS_SUCCESS) << "agree test failed:" << importType;
    }

    (void)HksDeleteKeyForDe(&keyAlias1, nullptr);
    (void)HksDeleteKeyForDe(&keyAlias2, nullptr);
}

static void ImportAgreeTest(uint32_t alg, uint32_t keySize)
{
    TestImportKey(alg, keySize, HKS_KEY_TYPE_PUBLIC_KEY);
#ifdef HKS_UNTRUSTED_RUNNING_ENV
    TestImportKey(alg, keySize, HKS_KEY_TYPE_PRIVATE_KEY);
#endif
    TestImportKey(alg, keySize, HKS_KEY_TYPE_KEY_PAIR);
}

/**
 * @tc.name: HksImportAgreeTest.HksImportAgreeTest001
 * @tc.desc: import x25519
 * @tc.type: FUNC normal
 */
HWTEST_F(HksImportAgreeTest, HksImportAgreeTest001, TestSize.Level0)
{
#ifdef _USE_OPENSSL_
    ImportAgreeTest(HKS_ALG_X25519, HKS_CURVE25519_KEY_SIZE_256);
#endif
}

/**
 * @tc.name: HksImportAgreeTest.HksImportAgreeTest002
 * @tc.desc: import ecc
 * @tc.type: FUNC normal
 */
HWTEST_F(HksImportAgreeTest, HksImportAgreeTest002, TestSize.Level0)
{
    ImportAgreeTest(HKS_ALG_ECC, HKS_ECC_KEY_SIZE_256);
}

/**
 * @tc.name: HksImportAgreeTest.HksImportAgreeTest003
 * @tc.desc: import dh 2048
 * @tc.type: FUNC normal
 */
HWTEST_F(HksImportAgreeTest, HksImportAgreeTest003, TestSize.Level0)
{
    ImportAgreeTest(HKS_ALG_DH, HKS_DH_KEY_SIZE_2048);
}

#ifdef HKS_UNTRUSTED_RUNNING_ENV
/**
 * @tc.name: HksImportAgreeTest.HksImportAgreeTest004
 * @tc.desc: import dh 2048
 * @tc.type: FUNC normal
 */
HWTEST_F(HksImportAgreeTest, HksImportAgreeTest004, TestSize.Level0)
{
    ImportAgreeTest(HKS_ALG_DH, HKS_DH_KEY_SIZE_3072);
}

/**
 * @tc.name: HksImportAgreeTest.HksImportAgreeTest005
 * @tc.desc: import dh 4096
 * @tc.type: FUNC normal
 */
HWTEST_F(HksImportAgreeTest, HksImportAgreeTest005, TestSize.Level0)
{
    ImportAgreeTest(HKS_ALG_DH, HKS_DH_KEY_SIZE_4096);
}
#endif
} // namespace Unittest::ImportAgreeTest

